Hello,
I am attempting to pull some records from a MySQL database using OR.
I basically want all records that correspond to one of three types.
For example, I want to pull the id for the records that are either example1, example2, or example3.
When I do this in PHPMyAdmin, it works just fine and I get all results I expect.
However, when I try in PHP, I only ever get the last result I expect. It is like it only gives me the end result of the last OR query.
Here is the code I am using:
$myquery = sprintf("SELECT id FROM products WHERE type = 'example1' OR type = 'example2' OR type = 'example3'");
$myresult = mysql_query($myquery);
$my = mysql_fetch_assoc($myresult);
echo '<pre>';
print_r($my);
This is the result of the above...
Array
(
[id] => 128
)
Does anyone have experience with using OR to get results to match specific types of records, based on the OR's?
I actually need to to give me the following (which is all the id results for the three types of products I am looking for):
Array
(
[id] => 128
[id] => 245
[id] => 246
)