[SOLVED] using DISTINCT and abiguous fields
Posted: Tue Feb 14, 2006 3:08 am
hy guys,
im trying to do a simple and faster query, but my problem is that i can select my ID column...
i have try use IN, JOIN and DISTINCT and the DISTINCT is the faster with 0.00 sec, IN takes to me 1.22sec and JOIN is something like 0.22sec but dont give me the results i wnat...
my poblem is that using DISTINCT im not able to select ID from my workers table, say that is abiguous...
here the 3 querys
i need some help with distinct because i need to use my ID field... some idea ??
thanks in advance
im trying to do a simple and faster query, but my problem is that i can select my ID column...
i have try use IN, JOIN and DISTINCT and the DISTINCT is the faster with 0.00 sec, IN takes to me 1.22sec and JOIN is something like 0.22sec but dont give me the results i wnat...
my poblem is that using DISTINCT im not able to select ID from my workers table, say that is abiguous...
here the 3 querys
id i take the id and left just surname and name will work fine...mysql> select distinct id,surname,name from workers,workers_positions where work
ers.id=id_worker;
ERROR 1052 (23000): Column 'id' in field list is ambiguous
and this one takes 1.22secmysql> select id,name from workers where id IN (select id_worker from workers_po
sitions );
and this one just dont help me because takes the 12results and displays the same name 12times... its just to show if im doing something wrong with this one...mysql> select name,surname from workers join workers_positions where workers.id=
id_worker;
i need some help with distinct because i need to use my ID field... some idea ??
thanks in advance