gausie Posted July 12, 2007 Share Posted July 12, 2007 SELECT mak.id,mak.name,mak.rating,mak.votes,mak.user,COUNT(comments.comment) AS num_comments FROM mak LEFT JOIN comments ON mak.id=comments.about GROUP BY mak.id ORDER BY num_comments DESC LIMIT 0,10 That query is selecting articles (in the table 'mak') based on how many comments (in the table 'comments') they have. However, I haven now implemented service comments and would like to discout them from the counting. Any service message is like this "<i>%</i>%" and since there is no other way of putting <i> into the comments field, I am sure that these are all service messages. How can I add this condition to the query I have above? gausie Link to comment https://forums.phpfreaks.com/topic/59549-solved-adding-some-conditions-to-a-query/ Share on other sites More sharing options...
btherl Posted July 12, 2007 Share Posted July 12, 2007 Try this: SELECT mak.id,mak.name,mak.rating,mak.votes,mak.user,COUNT(comments.comment) AS num_comments FROM mak LEFT JOIN comments ON mak.id=comments.about WHERE comments.comment NOT LIKE '<i>%</i>%' GROUP BY mak.id ORDER BY num_comments DESC LIMIT 0,10 Link to comment https://forums.phpfreaks.com/topic/59549-solved-adding-some-conditions-to-a-query/#findComment-296180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.