I have a table A with the following definition in MySQL
----------------------------------
id c_id t_id
-------------------------------
where c_id references cid on another table B with the following definition
================================================
id cid cname
=================================================
So i am issuing the following query
select group_concat(cname) as list
from A join B using (cid)
where t_id="something";
But I m getting the following error
Unknown column "cid" in from clause
I tried changing it to "c_id", but that doesnt seem to work either..
Any help is appreciated.
Thanks
USING
in MySQL is just a short form for a standard ON
clause, and only works when the column name is identical in both tables.
From the manual:
The USING(column_list) clause names a list of columns that must exist in both tables.
Instead, do this:
select group_concat(B.cname) as list
from A
inner join B on A.c_id = B.cid
where A.t_id = 'something';
Both columns need the same name: either c_id or cid Then the using clause will work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With