
April 9th, 2004, 07:29 PM
|
|
Contributing User
|
|
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73
Time spent in forums: 1 h 55 m 11 sec
Reputation Power: 7
|
|
|
Query, Inner Join?
I'm not sure if I need to be using inner join or not.
What I have is 2 database one called Topics the other being Replies, for a small forum type page.
I would like to select all topics and replies and list Topics from latest replies,
But if there's a new topic then it should be listed on top. Like a forum.
The queries below does what I need but I'm getting duplicate topics.
Topics
topicTitle = INT
topicMessage = TEXT
topicTime = Timestamp
Replies
replyID = INT
topicParent = INT
replyMessage = TEXT
replyTime = Timestamp
PHP Code:
SELECT topics.*, replies.*, topics.topicTime, replies.replyTime FROM topics INNER JOIN replies ON topics.topicID = replies.topicParent ORDER BY replies.replyTime DESC;
I also tried something like this.
SELECT topics.*, replies.* FROM topics, replies ORDER BY topics.topicTime and replies.replyTime DESC;
|