对不起,因为这是一个菜鸟问题。我是新与MySQL:这个MySQL查询有什么问题?
我写这样的查询:
SELECT
u.userid, u.alias, g.company_name,
v.endtime - v.begintime AS duration,
u.status, u.service_starttime,
u.service_expiretime, v.begintime, u.email
FROM
company_users c, company_groups g INNER JOIN
user_info u INNER JOIN vfon_log v
ON (u.userid = v.hostid) ON (g.company_id = u.company_id)
该查询返回一个语法错误:
Query : SELECT u.userid, u.alias, g.company_name, v.endtime - v.begintime AS duration, u.status, u.service_starttime, u.service_ex...
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON (g.company_id = u.company_id)
LIMIT 0, 1000' at line 4
Execution Time : 00:00:00:000
Transfer Time : 00:00:00:000
Total Time : 00:00:00:000
我花了30分钟找,但我可以弄清楚什么是错的。
非常感谢你对你的帮助
由于您正在使用MySQL,您可能需要将'v.endtime - v.begintime'更改为'TIMEDIFF(v.endtime,v.begintime)AS duration',因为这会给您一个正确格式化的时差。 – Mike 2010-07-12 08:46:40