简单的Postgresql语句-列名不存在 [英] Simple Postgresql Statement - column name does not exists

查看:256
本文介绍了简单的Postgresql语句-列名不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在拔头发.我有一个非常简单的postgre数据库,一个特定的表有一个名为lName(大写N)的列.现在,我知道使用postgre我必须引用lName,因为它包含一个大写的N.

I've been pulling my hair out. I have a very simple postgre database, one specific table has a column named lName (uppercase N). Now I know with postgre I must quote lName since it contains an uppercase N.

我正在尝试使用以下语句查询数据库:

I am trying to query the database with the following statement:

SELECT * 
FROM employee 
WHERE "lName" LIKE "Smith"

但是我收到此错误:

警告:pg_query() [function.pg-query]:查询失败: 错误:"Smith"列不存在 在.....

Warning: pg_query() [function.pg-query]: Query failed: ERROR: column "Smith" does not exist in .....

这是什么问题?为什么说该列为史密斯"?

What is the issue here? Why is it saying the column is "Smith"?

推荐答案

我猜:

 SELECT * FROM employee WHERE "lName" LIKE 'Smith'

(请注意不同的引号; "foo"是带引号的标识符; 'foo'是字符串文字)

(note the different quotes; "foo" is a quoted identifier; 'foo' is a string literal)

此外,在大多数SQL方言中,没有通配符的LIKE等同于=;您是要添加通配符吗?

Also, in most SQL dialects, a LIKE without a wildcard is equivalent to =; did you mean to include a wildcard?

这篇关于简单的Postgresql语句-列名不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆