0

I used postgresql DB.
This order is working.

# 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)

but, other condition's this order is not working.

# select * from test where old_code = "220088242";
ERROR:  column "220088242" does not exist
LINE 1: select * from test where old_code = "220088242";

this is DB's detail.

# \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)

what is problem?

1
  • Double quotes are for delimited identifiers, e.g. a column named 220088242 (very strange name...) Use single quotes for string literals, and no quotes at all for numeric literals. Commented Aug 13, 2018 at 9:44

2 Answers 2

2

in postgresql " " could be used to refer to a column or table named "select"

A string constant in SQL is an arbitrary sequence of characters bounded by single quotes ('), for example 'This is a string'.so this is not the same as a double-quote character (")

As a result you have to use single quote like below

select * from test where old_code = '220088242'
Sign up to request clarification or add additional context in comments.

Comments

0

use like clause

SELECT * FROM test WHERE old_code LIKE '220088242';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.