用and不行吗? SELECT note.author AS first,count(reply.title) AS second FROM note,reply WHERE note.n_id=reply.parent and second>5 GROUP BY first
对啊,直接WHERE note.n_id=reply.parent and second>5
没问题啊。这条SQL能够正常运行。是不是你在运行有没有选择数据库?用USE语句。 还有一点,你说/r_parent-〉回复对象。而你在SQL里用的是 parent。是不是这里的问题? 以下是运行后的屏幕截取。 mysql> SELECT note.author AS first,count(reply.title) AS second -> FROM note,reply -> WHERE note.n_id=reply.parent -> GROUP BY first -> HAVING second>5 -> ; +-------+--------+ | first | second | +-------+--------+ | t1 | 6 | +-------+--------+ 1 row in set (0.00 sec)
SELECT note.author AS first,count(reply.title) AS second
FROM note,reply
WHERE note.n_id=reply.parent and second>5
GROUP BY first
还有一点,你说/r_parent-〉回复对象。而你在SQL里用的是 parent。是不是这里的问题?
以下是运行后的屏幕截取。
mysql> SELECT note.author AS first,count(reply.title) AS second
-> FROM note,reply
-> WHERE note.n_id=reply.parent
-> GROUP BY first
-> HAVING second>5
-> ;
+-------+--------+
| first | second |
+-------+--------+
| t1 | 6 |
+-------+--------+
1 row in set (0.00 sec)