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.

Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69
YKJ
  • 387
  • 7
  • 16

1 Answers1

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;
Amit Bera
  • 77,456
  • 20
  • 123
  • 237
Anisha Shaikh
  • 429
  • 2
  • 5