對不起,因爲這是一個菜鳥問題。我是新與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