所以我在这个SQL查询中收到错误,但我自己也看不到自己的错误:
SELECT group_members.group_id,
group_members.permissions,
group.group_name
FROM group_members,
group
WHERE group_members.group_id=group.group_id
AND group.group_id = 1
错误:
#1064 - 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 'group WHERE group_members.group_id=group.group_id AND group.group_id = 1
感谢您的帮助!
答案 0 :(得分:3)
组是MySQL中的保留字,要么用反引号“`”括起来,要么更好,但不要将它用作表名
SELECT group_members.group_id, group_members.permissions, `group`.group_name
FROM group_members, `group`
WHERE group_members.group_id=`group`.group_id
AND `group`.group_id = 1
答案 1 :(得分:1)
试试这个
SELECT group_members.group_id, group_members.permissions, `group`.group_name
FROM group_members, group
WHERE group_members.group_id=`group`.group_id
AND `group`.group_id = 1