我只打印两个表数据,所以我使用内连接
SELECT sd.GameName
FROM LottoryTickets AS sd
JOIN group AS p
ON sd.Group = p.groupname
WHERE p.groupname = 11
现在我得到了#106 4 - 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 AS p ON sd.Group = p.groupname WHERE p.groupname = 11 LIMIT 0, 30' at line 3
这个回复请指导我
感谢您的进步。
答案 0 :(得分:6)
使用:
`group` //as group is a predefined keyword
答案 1 :(得分:3)
group
是MySQL中的关键字,如果你想用这个名称调用一个表,你必须用反引号括起名字;
SELECT sd.GameName
FROM LottoryTickets AS sd
JOIN `group` AS p
ON sd.Group = p.groupname
WHERE p.groupname = 11
答案 2 :(得分:0)
GROUP是ansi sql保留字。 eaven提交的代码很明显(组用蓝色着色)。
TRY
SELECT sd.GameName
FROM LottoryTickets AS sd
JOIN `group` AS p
ON sd.Group = p.groupname
WHERE p.groupname = 11