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! Quote Link to comment 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"; Quote Link to comment 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'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.