Jump to content

[SOLVED] SELECT w/multiple WHERE clauses compared with the same column.


boo_lolly

Recommended Posts

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?

 

@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!

@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.

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!

:D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.