努力让这个查询有效:
$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服务器版本 在'.username FROM questionnaires_index INNER JOIN附近使用的语法 用户ON users.id =问卷'在第1行
查询一直有效,直到我将users.username添加到带有JOIN语句的结果集。请帮忙。
答案 0 :(得分:1)
你错过了一个逗号
$ 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。”'))“;
答案 1 :(得分:0)
你似乎忘了在questionnaires_index.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."'))