s.spirit
s.spirit

Reputation: 343

SQL request to find item in table by value in column

Its pretty simple question, I know, but I really stacked with a problem with it...

I have a table customer_customer and a column code in it. So I need to find all items with a specific code value. So I wrote that:

SELECT * FROM customer_customer WHERE code LIKE "КL-12345"

and got an error:

column "КL-12345" does not exist

Why КL-12345 became a column if I specify it as value of code column? What am I doing wrong?

Upvotes: 1

Views: 45

Answers (2)

Kapil
Kapil

Reputation: 987

Change it to single quotes

SELECT * FROM customer_customer WHERE code LIKE 'КL-12345'

or

SELECT * FROM customer_customer WHERE code = 'КL-12345'

Upvotes: 2

user2877959
user2877959

Reputation: 1792

String literals must be enclosed in single quotes. By enclosing it in double quotes, you specified a variable name.

Also, note that your where condition is the same as writing

where code = 'КL-12345'

LIKE is used for pattern matching. For instance you would match all codes that contain 'KL-12345' like this

where code like '%KL-12345%'

Upvotes: 4

Related Questions