我有問題,這樣的代碼:SQL語法和SQL Server版本錯誤
$comments->query = "SELECT " . PREFIX . "_comments.id, post_id, " . PREFIX . "_comments.user_id, " . PREFIX . "_comments.date, " . PREFIX . "_comments.autor as gast_name, " . PREFIX . "_comments.email as gast_email, text, ip, is_register, name, " . USERPREFIX . "_users.email, news_num, " . USERPREFIX . "_users.comm_num, user_group, lastdate, reg_date, signature, foto, fullname, land, yahoo, " . USERPREFIX . "_users.xfields, " . PREFIX . "_post.title, " . PREFIX . "_post.date as newsdate, " . PREFIX . "_post.alt_name, " . PREFIX . "_post.category FROM " . PREFIX . "_comments LEFT JOIN " . PREFIX . "_post ON " . PREFIX . "_comments.post_id=" . PREFIX . "_post.id LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_comments.user_id=" . USERPREFIX . "_users.user_id " . $where . " ORDER BY id desc";
錯誤:
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 dle_comments.post_id=dle_post.id LEFT JOIN dle_users ON dle_comments.user_id=' at line 1
編輯:
SELECT
dle_comments.id, post_id,
dle_comments.user_id,
dle_comments.date,
dle_comments.autor as gast_name,
dle_comments.email as gast_email,
text, ip, is_register,
group_concat(mid) as `awards`,
name, dle_users.email, news_num,
dle_users.comm_num, user_group,
lastdate, reg_date, signature,
foto, fullname, land, icq,
dle_users.xfields, dle_post.title,
dle_post.date as newsdate, dle_post.alt_name, dle_post.category
FROM
dle_comments
LEFT JOIN dle_awards
ON uid = dle_post
ON dle_comments.post_id=dle_post.id
LEFT JOIN dle_users
ON dle_comments.user_id=dle_users.user_id
ORDER BY id desc
LIMIT 0,30
我的SQL版本:5.5 .20
我該如何解決這個問題?
你可以發表迴應或打印的查詢?與所有PREFIX等,它幾乎是不可讀的... – arnoudhgz 2012-08-06 20:54:52
我添加了一個完整的錯誤 – Alireza 2012-08-06 20:58:53
請在您的查詢中放一些換行符....我試圖編輯它,但我沒有看到我的更改。 – arnoudhgz 2012-08-06 21:05:40