我使用了postgresql DB。
此顺序有效。
# select * from test where id=3299;
id | m_id | old_code | new_code | log_date
--------+--------+-----------+-----------+----------------------------
3299 | 603990 | 220088242 | 234024141 | 2018-08-09 18:40:05.655615
(1 row)
但是,其他条件的此顺序不起作用。
# select * from test where old_code = "220088242";
ERROR: column "220088242" does not exist
LINE 1: select * from test where old_code = "220088242";
这是DB的详细信息。
# d test;
Table "test"
Column | Type | Modifiers
-----------------
id | integer | not null default nextval('test_id
_seq'::regclass)
m_id | integer |
old_code | character varying(12) |
new_code | character varying(12) |
log_date | timestamp without time zone |
Indexes:
"l_shina_pkey" PRIMARY KEY, btree (id)
什么是问题?
in postgresql " " 可用于指代名为"select"的列或表
SQL 中的字符串常量是由单引号 ('( 限定的任意字符序列,例如"This is a string"。因此这与双引号字符 ("(
不同。因此,您必须使用如下所示的单引号
select * from test where old_code = '220088242'
使用 like 子句
SELECT * FROM test WHERE old_code LIKE '220088242';