Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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.
Thanks in Advance.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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