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?

 

Link to comment
Share on other sites

@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
Share on other sites

@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
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.