Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > Databases - MySQL, SQL, Oracle, Access and others
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-01-2005, 09:56 AM   #1 (permalink)
tiffn
Junior Member
 
Join Date: Jul 2005
Posts: 28
Default join two queries?

Hi,

What I have is the first query selects the information about the writers article, and the second query selects the comments about the article.
Code:
$id = $_GET['id']; $query = "SELECT * FROM writer_articles WHERE id = $id ORDER BY date_time DESC";
and the second
Code:
$query = "SELECT * FROM writer_comments WHERE id = $id ORDER BY date_time DESC";
I have tried putting FROM writer_articles, writer_comments in the same query but that doesn't work. I think it should be done with a join, but i don't understnad how to put it all together. Advice appreciated.
tia
tiffn is offline   Reply With Quote
Sponsored Links
Old 11-03-2005, 07:12 PM   #2 (permalink)
websitedatabases
Junior Member
 
Join Date: Jul 2005
Posts: 12
Default

Give this a try:
Code:
SELECT * FROM writer_articles a INNER JOIN writer_comments c ON c.id = a.id WHERE a.id = $id ORDER BY date_time DESC
websitedatabases is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 02:55 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums