Re: Aliased mysql queries and mysql_fetch_array()
| From: | John Holmes | Date: | Fri, 22 Oct 2004 23:24:44 +0000 |
| Subject: | Re: Aliased mysql queries and mysql_fetch_array() | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36993@lists.php.net to get a copy of this message | ||
Philip Thompson wrote:
I have the query to pull the information - and I know it works for everything else. Now how do I reference the director/manager to store it in a variable without having to use numerical indexing? --------------------$query = "select projects.*, locations.*, funding.*, people.* from people as people_1 RIGHT JOIN " .[snip]
Do you really need to select _every_ column from _all_ of those tables? To solve your problem, you need to select the columns with aliases... $query = "SELECT people_1.first_name as p1_first_name, people.first_name as p_first_name, ..."; Now you'll have $row['p1_first_name'] and $row['p_first_name'] available. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com$_SESSION["director"][$i] = $row["people_1.first_name"] . " " . $row["people_1.last_name"];