Re: Join - Two Columns with the same name
| From: | Warren Vail | Date: | Thu, 13 Apr 2006 22:55:04 +0000 |
| Subject: | Re: Join - Two Columns with the same name | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233953@lists.php.net to get a copy of this message | ||
Several methods are supported by mysql, here is the one I like,
select * from table1 a, table2 b where a.col1 = b.col1
In this case the a and b are "aliases" of table1 and table2 respectively and the notation a.col1 and b.col1 refers to column "col1" in table1 and table2 respectively. You can used the same notation in left and right joins if you don't want to use the hard join illustrated here. (In a hard join, if the value in table1 is missing from table2 no row is returned, even if one exists in table 1).
hope this helps,
Warren Vail
At 03:29 PM 4/13/2006, Kevin Murphy wrote:
This is probably basic, but I can't seem to find the answer. Is there a way to specify in a join a specific column when the two tables have columns with the same name? Something like: $row['table1.id'] vs $row['table2.id'] -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu 775-445-3326 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php