PHP高手回答

来源:百度知道 编辑:UC知道 时间:2024/05/12 14:48:33
SELECT topic.*,COUNT('comment'.c_t_ID) AS comment_count
FROM topic LEFT JOIN 'comment' ON topic.t_ID = 'comment'.c_t_ID
GROUP BY topic.t_ID
ORDER BY t_ID DESC
出现这样的错误: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 '.c_t_ID) AS comment_count FROM topic LEFT JOIN 'comment' ON topic.t_ID = 'commen' at line 1

教你如何设计SQL错误:
1.根据错误提示调试
near '.c_t_ID) AS comment_count FROM topic LEFT JOIN 'comment' ON topic.t_ID = 'commen' at line 1 .near关键字说明错误出现在附近
2.将SQL语句复制到数据库环境下执行看是否有错
3.去掉表外边的引号试试

表名不能用引号的吧!要用也得用反单引号`comment`