query in codeIgniter style
- by troy
I have below query:
SET @sql = NULL ;
SELECT GROUP_CONCAT( DISTINCT CONCAT( 'select latitude,longitude,max(serverTime) as serverTime,', deviceID, ' AS device from d', deviceID, '_gps' )
SEPARATOR ' UNION ALL ' )
INTO @sql
FROM devices
WHERE accountID =2;
PREPARE stmt FROM @sql ;
EXECUTE stmt;
Can someone help me to write the above…