Jump to content

prblem in join


birbal

Recommended Posts

i have two tables which i am joining by equi join. now i have a same column name in both table. i am using it with php. so when i am fetching it from database resource how can i refer a particular column from a particular table.

Link to comment
Share on other sites

SELECT somethingFROM somewhereWHERE something=value
not so...i am not asking for query syntax. i meantable1 has a column name borntable2 has a column name born toonow i did equi join to both table. so new joined table has two column same name(born)$res=mysql_query($qry);$row=$mysql_fetch_assoc($res);now how can i get particularly table1 column born?$row['born'] as both field name is born in joined table
Link to comment
Share on other sites

You need to use an alias, which means you need to list each column out. I'm not sure if there's another way to give an entire table an alias that applies to all columns. e.g.:SELECT t1.name AS table1_name, t2.name AS table2_name ...You only need to list the table prefix if the field is in both tables.

Link to comment
Share on other sites

You need to use an alias, which means you need to list each column out. I'm not sure if there's another way to give an entire table an alias that applies to all columns. e.g.:SELECT t1.name AS table1_name, t2.name AS table2_name ...You only need to list the table prefix if the field is in both tables.
thanks it is solved now. i tried that table alias before but it was too returning same column name. which is ok at mysql but it was creating trouble at the php fetching time.had to give alias to all common tables.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...