Click to See Complete Forum and Search --> : Duplicate fields when joining tables with MySQL


slyfox
02-26-2004, 07:53 PM
Hi Friends

I am joining two tables but the problem is that in both tables some of the fields has the same name, how do I get past this?? Maybe create variables in mySQL (if that can be done) for the second set of fields "with duplicate names" (almost like temporary field names)...

Here is my query joining two tables:select t1.abc,t1.xyz,t2.abc,t2.xyz from t1,t2 where code=1 and t2.id=t1.id
Thanks for your help... well, any help!:)

drewex
02-26-2004, 08:39 PM
try this

select t1.abc,t1.xyz,t2.abc,t2.xyz from t1 join t2 on t2.id=t1.id
where code=1

and check the code isnt on both sides. if it is on both sides and you want both to be 1 then do this


select t1.abc,t1.xyz,t2.abc,t2.xyz from t1 join t2 on t2.id=t1.id
and t2.code=t1.code where t1.code=1