0

努力让这个查询工作:

$query_search = "SELECT questionnaires_index.id, questionnaires_index.ea_num, questionnaires_index.address, questionnaires_index.status, questionnaires_index.json_stored users.username FROM questionnaires_index INNER JOIN users ON questionnaires_index.interviewer_id = users.id WHERE questionnaires_index.interviewer_id IN (SELECT GROUP_CONCAT(id) FROM users WHERE supervisor = (SELECT id FROM users WHERE username = '".$username."'))";

收到此错误:

查询错误:。您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“.username FROM questions_index INNER JOIN users ON users.id = questions”附近使用正确的语法

该查询一直有效,直到我使用 JOIN 语句将 users.username 添加到结果集中。请提供任何帮助。

4

2 回答 2

1

你漏了一个逗号

$query_search = "选择问卷调查索引.id,问卷调查索引.ea_num,问卷调查索引.地址,问卷调查索引状态,问卷调查索引.json_stored,users.username FROM问卷调查索引内部加入用户问卷调查_index.interviewer_id = users.id WHERE问卷调查索引.interviewer_id IN (SELECT GROUP_CONCAT( id) FROM users WHERE supervisor = (SELECT id FROM users WHERE username = '".$username."'))";

于 2012-07-30T12:19:06.693 回答
0

您似乎忘记在问卷调查索引.json_stored 和 users.username 之间加逗号。

$query_search = "SELECT questionnaires_index.id, questionnaires_index.ea_num, questionnaires_index.address, questionnaires_index.status, questionnaires_index.json_stored ,users.username FROM questionnaires_index INNER JOIN users ON questionnaires_index.interviewer_id = users.id WHERE questionnaires_index.interviewer_id IN (SELECT GROUP_CONCAT(id) FROM users WHERE supervisor = (SELECT id FROM users WHERE username = '".$username."'))
于 2012-07-30T12:21:46.530 回答