我有下表,我想选择所有(通过 php 查询)但只选择与 course1 匹配的行,我尝试了以下但它不起作用。
$comments = array();
$result = mysql_query("select * from comments where course1='$post_id' order by id ASC");
什么是正确的查询?
+----+-----------+----------+-----+-------------------------+---------------+-------------
| id | post_id | name | url | email | body | dt |
+----+-----------+----------+-----+-------------------------+---------------+-------------
| 1 | course2 | john | | john@john.com | comments by john | 2012-11-16 |
| 2 | course1 | wiki | | wiki@wiki.com | comments by wiki | 2012-11-16 |
| 3 | course2 | daniel | | daniel@gmail.com | comments by daniel | 2012-11-16 |
| 4 | course2 | ram | | ram@ram.com | comments by ram | 2012-11-16 |
| 5 | course1 | velu | | velu@velu.com | comments by velu | 2012-11-16 |
+----+-----------+----------+-----+-------------------------+---------------+-------------