Jump to content

Query not retrieving rows with 0


Eiolon

Recommended Posts

I made a forum and it works for the most part.  The problem I have is when I query for the list of topics in the forum, anything with 0 replies does not get shown.  Once I have a reply to that topic it gets shown.  Here is the query:

 

SELECT t.*, r.*, DATE_FORMAT(t.topic_last_reply, '%c/%e/%Y %l:%i %p') AS convdate FROM topics t LEFT JOIN replies r ON (t.topic_id = r.reply_topic) WHERE t.topic_forum = ".$_GET['forum_id']." GROUP BY t.topic_subject HAVING t.topic_num_replies >= 0 ORDER BY t.topic_last_reply DESC

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/79131-query-not-retrieving-rows-with-0/
Share on other sites

Sorry, I am a novice.  When you mean variable interpolation, what do you mean?  Like this?

 

// Query the database for topic and reply information.
$query_topics = "SELECT t.*, r.*, DATE_FORMAT(t.topic_last_reply, '%c/%e/%Y %l:%i %p') AS convdate FROM topics t LEFT JOIN replies r ON (t.topic_id = r.reply_topic) WHERE t.topic_forum = ".$_GET['forum_id']." GROUP BY t.topic_subject ORDER BY t.topic_last_reply DESC";
$topics = mysql_query($query_topics) OR die ('Cannot retrieve a list of topics.');
$row_topics = mysql_fetch_array($topics);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.