gpt4 book ai didi

mysql - 在 Mysql 中使用关键字

转载 作者:IT王子 更新时间:2023-10-29 00:31:58 26 4
gpt4 key购买 nike

我在 MySQL 中有一个表 A,定义如下

----------------------------------
id c_id t_id
-------------------------------

其中 c_id 引用另一个表 B 上的 cid,定义如下

================================================
id cid cname
=================================================

所以我发出以下查询

select group_concat(cname) as list
from A join B using (cid)
where t_id="something";

但我收到以下错误

Unknown column "cid" in from clause

我尝试将其更改为“c_id”,但这似乎也不起作用..

感谢任何帮助。

谢谢

最佳答案

MySQL 中的

USING 只是标准 ON 子句的缩写形式,并且仅在两个表中的列名相同时才有效。

来自 the manual :

The USING(column_list) clause names a list of columns that must exist in both tables.

相反,这样做:

select group_concat(B.cname) as list 
from A
inner join B on A.c_id = B.cid
where A.t_id = 'something';

关于mysql - 在 Mysql 中使用关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11549525/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com