select substring(member.own,3,4), count (*)
from member, amphur
Where amphur.AMPHUR_CODE = substring(member.own,3,4)
group by substring(member.own,3,4)
1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在成员,amphur附近的'*)附近使用正确的语法。其中amphur.AMPHUR_CODE = substring(member.own,3,4)g'在第1行
答案 0 :(得分:2)
删除COUNT
和(*)
之间的空格。如果有空格,MySQL不会将“count”识别为函数。
答案 1 :(得分:0)
SELECT SUBSTRING(m.own,3,4),
COUNT(* ) AS cnt
FROM MEMBER AS m,
amphur AS a
WHERE a.AMPHUR_CODE COLLATE utf8_general_ci = SUBSTRING(m.own,3,4)
GROUP BY SUBSTRING(m.own,3,4)