我试图让MySQL查询正常工作但仍然出错。我想加入两个表tbl_collab
和tbl.uploads
并加上WHERE
条款,但无法弄清楚我遇到了什么问题。感谢。
SELECT tbl_collab.collab_userid, tbl_collab.file, tbl_collab.tbl_upload_id,
tbl_uploads.id,tbl_uploads.title,
FROM tbl_uploads
LEFT JOIN tbl_uploads.id ON tbl_collab.tbl_upload_id
WHERE tbl_collab.collab_userid='2'
我收到此错误:
#1064 - 您的SQL语法出错;检查与您的MySQL服务器版本相对应的手册,以便在#tbl_uploads LEFT JOIN附近使用正确的语法tbl_uploads.id ON tbl_collab.tbl_upload_id WHERE'在第3行
答案 0 :(得分:1)
来自和左连接后的整个语法错误。 请按以下查询更新。
试试这个:
SELECT tbl_collab.collab_userid,
tbl_collab.file,
tbl_collab.tbl_upload_id,
tbl_uploads.id,
tbl_uploads.title
FROM tbl_collab
LEFT JOIN tbl_uploads ON tbl_uploads.id = tbl_collab.tbl_upload_id
WHERE tbl_collab.collab_userid='2'
答案 1 :(得分:0)
在tbl_uploads_title之后的SELECT子句中有一个逗号(,)应删除。
答案 2 :(得分:0)
SELECT tbl_collab.collab_userid, tbl_collab.file, tbl_collab.tbl_upload_id, tbl_uploads.id,tbl_uploads.title FROM tbl_uploads LEFT JOIN tbl_uploads.id ON tbl_collab.tbl_upload_id WHERE tbl_collab.collab_userid='2`
在FROM
之前删除逗号