boo_lolly Posted April 20, 2007 Share Posted April 20, 2007 i wasn't sure what to call this topic, but basically i'm trying to select a handful of rows from my table that match a handful of id's. so, something like: $sql = " SELECT * FROM bio WHERE id = '2', id = '5', id = '12', id = '4' "; i want to grab the specified rows, but for some reason i can't structure the query in a proper fashion. can someone help me with this query? Link to comment https://forums.phpfreaks.com/topic/47924-solved-select-wmultiple-where-clauses-compared-with-the-same-column/ Share on other sites More sharing options...
Wildbug Posted April 20, 2007 Share Posted April 20, 2007 SELECT * FROM bio WHERE id = '2' OR id = '5' OR id = '12' OR id = '4' Link to comment https://forums.phpfreaks.com/topic/47924-solved-select-wmultiple-where-clauses-compared-with-the-same-column/#findComment-234194 Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 Or, even better: WHERE ID in ('2','5','12','4') Link to comment https://forums.phpfreaks.com/topic/47924-solved-select-wmultiple-where-clauses-compared-with-the-same-column/#findComment-234203 Share on other sites More sharing options...
boo_lolly Posted April 20, 2007 Author Share Posted April 20, 2007 @wildbug - that only selects ONE of them, not all of them. i've tried a LOT of different clauses like MATCH and AGAINST... none of them work. i refuse to run a single query for each id and pump the results into another array, and use the results from there... i know there's a way mysql can do this... but i have no idea how. @fenway - unfortunately, that only selects one of them as well... very nice try, but no dice =\ EDIT: fenway, that works great. the reason why i thought it didn't work was because i was printing out my query to the browser, and also printing out the results of my query to the browser. it was only showing one of the two results, and the reason why was because that row was had nothing but empty fields =). so wildbug, your query may have worked too! =) thanks everybody. topic solved! Link to comment https://forums.phpfreaks.com/topic/47924-solved-select-wmultiple-where-clauses-compared-with-the-same-column/#findComment-234211 Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 @wildbug - that only selects ONE of them, not all of them. i've tried a LOT of different clauses like MATCH and AGAINST... none of them work. i refuse to run a single query for each id and pump the results into another array, and use the results from there... i know there's a way mysql can do this... but i have no idea how. @fenway - unfortunately, that only selects one of them as well... very nice try, but no dice =\ Then you don't have those IDs in your table. Link to comment https://forums.phpfreaks.com/topic/47924-solved-select-wmultiple-where-clauses-compared-with-the-same-column/#findComment-234213 Share on other sites More sharing options...
boo_lolly Posted April 20, 2007 Author Share Posted April 20, 2007 Then you don't have those IDs in your table. EDIT: fenway, that works great. the reason why i thought it didn't work was because i was printing out my query to the browser, and also printing out the results of my query to the browser. it was only showing one of the two results, and the reason why was because that row was had nothing but empty fields =). so wildbug, your query may have worked too! =) thanks everybody. topic solved! Link to comment https://forums.phpfreaks.com/topic/47924-solved-select-wmultiple-where-clauses-compared-with-the-same-column/#findComment-234214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.