mySQL - select column
| From: | Julian Wood | Date: | Wed, 18 Apr 2001 06:48:39 +0000 |
| Subject: | mySQL - select column | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49133@lists.php.net to get a copy of this message | ||
Hi all,
Given that the resultset from a mysql query is a 2-d array (of sorts - I
don't know), if I retrieve only a single column, is there an easy way to
grab it as a linear array? For example - old way:
$uids=array();
$res = mysql_db_query("db", 'select uid from tbl;', $link);
while ($row = mysql_fetch_row($res)) {
array_push ($uids, $row[0]);
}
It seems a little redundant to make another array if one already exists. The
end idea is to get to a list of uids ($uid_str = join(',',$uids)) that can
be used in a second query to the db (to make up for the lack of subqueries
in mysql). I guess what I'm asking - can you do a join on the mysql
resultset array somehow. I know in the perl DBI you can get a column of
results, but can't find it in php.
Thx.
J
--
Julian Wood
Learning Technologies and Digital Media
University of Calgary