SunQuest
 
           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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 21st, 2003, 03:51 AM
matscott matscott is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 matscott User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
run two queries consecutively

I have the following problem that I think would be fairly simple for any vet. I am a newbie so please bear with me.
I am writing a simple shopping cart using php mysql.
I have reached a point where I need to run a query, then run another query to a different table based on the result of the first. This may need to happen more than once.
Background.
I have a table for my basket and a table for item descriptions. My basket query requests all records with a certain order_id number, this will contain the item_id. I wish to then query the item table to output the item description.

I hope this is clear enough, I really need to know the best way of doing this.

Reply With Quote
  #2  
Old November 21st, 2003, 06:51 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
If the two tables share a key (item_id), then you should be able to do a simple join to get the description in one query. Something like:

Code:
SELECT description FROM item_tbl, order_tbl WHERE order_tbl.item_id=item_tbl.item_id AND order_tbl.order_id=X

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > run two queries consecutively


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 2 hosted by Hostway