sql语句错误:“列..不存在"

编程入门 行业动态 更新时间:2024-10-11 17:22:46
本文介绍了sql语句错误:“列..不存在"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在从Postgres控制台尝试以下命令:

Im trying from postgres console this command:

select sim.id as idsim, num.id as idnum from main_sim sim left join main_number num on (FK_Numbers_id=num.id);

我得到了这个答复:

ERROR: column "fk_numbers_id" does not exist LINE 1: ...m from main_sim sim left join main_number num on (FK_Numbers...

但是如果我只是用以下方法检查表:

but if I simply check my table with:

dbMobile=# \d main_sim id | integer | not null default Iccid | character varying(19) | not null ... FK_Device_id | integer | FK_Numbers_id | integer | Indexes: "main_sim_pkey" PRIMARY KEY, btree (id) "main_sim_FK_Numbers_id_key" UNIQUE, btree ("FK_Numbers_id") "main_sim_Iccid_key" UNIQUE, btree ("Iccid") "main_sim_FK_Device_id" btree ("FK_Device_id") Foreign-key constraints: "FK_Device_id_refs_id_480a73d1" FOREIGN KEY ("FK_Device_id") REFERENCES main_device(id) DEFERRABLE INITIALLY DEFERRED "FK_Numbers_id_refs_id_380cb036" FOREIGN KEY ("FK_Numbers_id") REFERENCES main_number(id) DEFERRABLE INITIALLY DEFERRED

...我们可以看到该列存在.

...as we can see the column exist.

可能是语法错误,但是我看不到什么...

probably it's syntax error, but I'm unable to see what...

任何帮助将不胜感激. 阿莱西奥

any help will'be appreciated. Alessio

推荐答案

否,列FK_Numbers_id不存在,仅列"FK_Numbers_id"存在

No, the column FK_Numbers_id does not exist, only a column "FK_Numbers_id" exists

显然,您使用双引号创建了表,因此,所有列名现在都区分大小写,并且必须始终使用双引号:

Apparently you created the table using double quotes and therefor all column names are now case-sensitive and you have to use double quotes all the time:

select sim.id as idsim, num.id as idnum from main_sim sim left join main_number num on ("FK_Numbers_id" = num.id);

回顾一下已记录的内容在手册中:

列foo和FOO相同,列"foo"和"FOO"不相同.

The column foo and FOO are identical, the columns "foo" and "FOO" are not.

更多推荐

sql语句错误:“列..不存在"

本文发布于:2023-07-21 03:39:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1173721.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不存在   语句   错误   sql   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!