General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 9th, 2004, 07:29 PM
zigote zigote is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Atlanta GA
Posts: 73 zigote User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.topicTimereplies.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 topicsreplies ORDER BY topics.topicTime and replies.replyTime DESC

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Query, Inner Join?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT