|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > run two queries consecutively |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|