您是否发现此查询有任何问题?
SELECT * FROM requests
WHERE id = '".$id."'
LEFT JOIN request_data ON (requests.id = request_data.request_id)
GROUP BY requests.id
已经工作了一段时间,但似乎无法正确使用它!
数据库如下所示:
-requests
-id
-another column
-and a third one
-request_data
-request_id
-key
-value
编辑:哦,对,错误:
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 'LEFT JOIN request_data ON (requests.id = request_data.request_id) GROUP BY ' at line 3
有什么想法吗?
答案 0 :(得分:2)
WHERE
位置错误。
SELECT *
FROM requests
LEFT JOIN request_data ON (requests.id = request_data.request_id)
WHERE id = '".$id."'
您可能不需要GROUP BY
因为WHERE
确保只返回一个id
,除非您以某种方式依赖隐藏列功能(您不应该是the results are undefined)。