Re: [PHP] Join - Two Columns with the same name

2006-04-13 Thread Jochem Maas

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']



yes. http://dev.mysql.com/doc/ is a good place to starting reading
up on SQL JOIN syntax.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Join - Two Columns with the same name

2006-04-13 Thread Warren Vail

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




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php