3

I want to fire select query which is as follows

SET @a = 0;
SELECT @a:=@a+1 as count FROM admin_user;

How I can add SET variable in SQL query in magento.

6

First you have run this Query

/* Get the  core resource model */
$resource = Mage::getSingleton('core/resource');

/*  Retrieve the read connection */
 $readConnection = $resource->getConnection('core_read');
 $query = 'SELECT @cnt:= 0 ;';
 $results = $readConnection->fetchAll($query);

Then Your Query i:e

SELECT @a:=@a+1 as count FROM admin_user;
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.