我写了一个像这样的准备语句,工作正常。在mysql中准备一个Prepare语句并在其中使用convert_tz
BEGIN
SET @tempaccountID :=CONCAT('\'',accountID1,'\'');
SET @tempdeviceID := CONCAT('\'',deviceID1,'\'');
SET @query :=CONCAT('select accountID,
deviceID,
FROM_UNIXTIME(timestamp) as timestamp,
statusCode,
latitude,
longitude,
speedKPH,
heading,
address,
odometerKM,
Charging
from ',(SELECT eventtableName FROM migration_run_time WHERE accountID=accountId1 AND deviceID=deviceID1),
' where accountID=',@tempaccountID,
' and deviceID=',@tempdeviceID,
' and latitude!=0.0 and longitude!=0.0 and speedKPH<120 and timestamp= (select max(timestamp) from ', (SELECT eventtableName FROM migration_run_time WHERE accountID=accountId1 AND deviceID=deviceID1) ,
' where accountID=',@tempaccountID,
' and deviceID=',@tempdeviceID,
' and latitude!=0.0 and longitude!=0.0 and speedKPH<120);');
PREPARE stmt FROM @query;
EXECUTE stmt;
现在来大问题
我想用CONVERT_TZ在声明中获得的时间所需时间格式这样
convert_tz(FROM_UNIXTIME(timestamp),device.timeZone,device.requiredTimeZone) as timestamp
//设备与另一个表在上面声明
如果我将以上述方式编写此代码,则必须在coloumn名称前缀中添加表名称,但事件表本身是在运行时计算的帐户ID和设备ID的基础..
我应该怎么做呢?
附:我在MySQL非常糟糕..我是一个> net/jQuery开发人员,并没有关于mysql的IDea。请帮助.. :(
感谢您的回答..让我试试看.. :) – writeToBhuwan 2013-04-08 09:05:08
不工作..在这种情况下,Convert_tz正在退步null .. – writeToBhuwan 2013-04-08 11:09:06
让我看看表格。 – fancyPants 2013-04-08 11:19:08