我有以下查询:
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;
有人可以帮我以 codeIgniter 风格编写上述查询....
另一件事是:以 1 和 2 格式编写查询有什么区别
1. $query = $this->db->query('YOUR QUERY HERE');
2. $this->db->select("...");
$this->db->from();
$this->db->where();
如果我们使用 2nd 样式,它会对性能有什么影响吗...谢谢