advancedfuture Posted April 22, 2008 Share Posted April 22, 2008 So I don't know exactly how to form a query to select a certain value from multiple items in the database. I have a table called items.. in that table are 2 rows, item_name and item_cost I have 4 items in the database. it looks as follows item_name | item_cost ------------------------ book | 100 candy | 45 flashlight | 75 gum | 10 I want to get the individual item_cost of only book and flashlight.. I know how to do this in 2 seperate queries, but is there a way I can get the item_cost for those those items in a single query? Thanks! Link to comment https://forums.phpfreaks.com/topic/102270-selecting-something-from-multiple-table-items/ Share on other sites More sharing options...
advancedfuture Posted April 22, 2008 Author Share Posted April 22, 2008 ok let me rephrase, i guess it would be easier to ask this. How do I combine these 2 queries into one.. that will solve my problem $query = "SELECT * FROM toon WHERE name='$username'"; $query2 = "SELECT * FROM items"; Link to comment https://forums.phpfreaks.com/topic/102270-selecting-something-from-multiple-table-items/#findComment-523665 Share on other sites More sharing options...
trq Posted April 22, 2008 Share Posted April 22, 2008 SELECT item_cost FROM items WHERE item_name IN('book','flashlight'); Link to comment https://forums.phpfreaks.com/topic/102270-selecting-something-from-multiple-table-items/#findComment-523689 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.