任何人都可以在我的表连接语句中找到语法错​​误吗?

时间:2013-12-02 18:30:05

标签: mysql select join

我觉得我在这里犯了一个明显的错误,但我一直在看它太久了。每当我运行这一行时:

SELECT CONCAT(Name, ' in ', city, ', ', statecode) AS 'Publisher Name and Location', COUNT(ISBN) AS '# Books', Max(Length(Title)) AS 'Longest Title', Min(Length(Title)) AS 'Shortest Title', 
FROM publisher
JOIN book ON (publisher.publisherID = book.publisherID)
WHERE INSTR(name, 'read') > 0 
GROUP BY Name
HAVING COUNT(ISBN) > 1;

我收到一条错误消息,指出'FROM publisher JOIN book ON(publisher.publisherID = book.publisherID)WHERE INS'

出现语法错误

4 个答案:

答案 0 :(得分:1)

删除逗号

AS 'Shortest Title',  FROM publisher 
                   ^----here

答案 1 :(得分:1)

移除,

前面的FROM publisher JOIN book

答案 2 :(得分:1)

通过删除AS 'Shortest Title', FROM publisher中的逗号来尝试此操作:

SELECT CONCAT(Name, ' in ', city, ', ', statecode) AS "Publisher Name 
and Location", COUNT(ISBN) AS "# Books", 
Max(Length(Title)) AS "Longest Title", Min(Length(Title)) AS "Shortest Title" 
FROM publisher JOIN book ON (publisher.publisherID = book.publisherID) 
WHERE INSTR(name, 'read') > 0 GROUP BY Name HAVING COUNT(ISBN) > 1;

答案 3 :(得分:0)

是否有可能是因为您在同一声明中有WHEREHAVING