Posted by:
SocQS
(---.dsl.irvnca.pacbell.net)
I'm trying to select the data held in column x of every row where column y equals someString. If you could imagine a table with 2 columns (Column1, Column2) and the following entries:
Column1-----Column2
Chuck--------tiger
Chuck--------lion
Matt---------elephant
From this table I would want all the data from Column2 where Column1 equals Chuck (i.e. tiger and lion). When I run my code only the data from the first instance of Chuck (where Column2 is tiger) is retrieved. What code can I use to retrieve both the tiger and lion values?
Here is my code thus far (minus some bits impertinent to this post):
$prepared = $database->prepare("SELECT Column2 FROM DatabaseName WHERE Column1 = Chuck"
;
$prepared->execute();
$toReturn = $prepared-> fetch(PDO::FETCH_ASSOC);
return $toReturn;
Thanks
Edit-Smiley face is unintentional; should be a )
Edited 1 time(s). Last edit at 02/24/2013 08:53AM by SocQS.