我似乎无法让这个查询工作,有人可以帮我修复它。MySQL查询问题
这里是MySQL代码。
SELECT users.(user_id, pic, first_name, last_name, username),
comments.(id, user_id, date_created)
FROM users
INNER JOIN comments ON users.user_id = comments.user_id
WHERE comments.user_id = '$user_id'
GROUP BY comments.date_created
我得到以下错误:
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 '(user_id, pic, first_name, last_name, username), comments.(id, user_id, date_created)' at line 1
你有什么问题? – 2010-07-09 05:19:38
稍有不同,您应该考虑使用[prepared statements](http://php.net/manual/en/mysqli.prepare.php)代替动态SQL命令。这是一个更安全的选择,并且通常比所有不必要的恶意转义都要简单。有很多教程。下面是一些让你开始使用的内容:[在PHP和MySQLi中准备的语句](http://mattbango.com/notebook/web-development/prepared-statements-in-php-and-mysqli/)和[开发MySQL数据库应用程序用PHP](http://developers.sun.com/databases/articles/mysql_php1.html)。 – Mike 2010-07-09 07:10:07