Hi all!
Long time reader of the forums, first time poster!
First table design:
Topics table:
id (int 10)
topic_id (int 10)
topic_title (tinytext)
Replies table:
topic_id (int 10)
reply_id (int 10)
posters_name (varchar 255)
I have a problem, I am trying to select all topics from the Topics table where there has been no reply. When a reply is made, the topic_id is inserted into the Replies table. So if I replied to topic id #10, the replies table would now include a record with the topic_id #10, the id to the reply (not important) and the name of the poster who replied (posters_name). Pretty simple design.
Let's assume I am doing this query for the poster named "timmy". My question is this, how do I select all rows from Topics where timmy hasn't replied to that topic? I've tried queries such as:
$query = mysql_query("SELECT DISTINCT * FROM Topics JOIN Replies ON Topics.topic_id != Replies.topic_id AND Replies.posters_name = 'timmy' LIMIT 0,1");
This query would work great if I removed the AND condition (Replies.posters_name = 'timmy') and wasn't picky about who made the reply. Since I want to select only those rows where timmy didn't reply, I figured the AND condition would work, but it falls on it's face miserably.
Please help me out, I would really appreciate it!
James