0

I am trying to update a value in my Postgres table:

CREATE TABLE restaurants 
(
    id BIGSERIAL NOT NULL,
    name VARCHAR(50) NOT NULL,
    location VARCHAR(50) NOT NULL,
    price_range INT NOT NULL CHECK (price_range >= 1 AND price_range <=5)
);

Here is the update that wouldn't work:

UPDATE restaurants 
SET location = ”los angeles”,
    name = ‘tacos los guichos’,
    price_range = 2
WHERE id = 27; 

The terminal says:

ERROR: syntax error at or near "angeles”"
LINE 3: location=”los angeles”,
^

My table does not seem to like strings when updating, even though I am able to insert them. So I am not sure why? When I removed the name and location column, it updated fine.

2
  • 3
    Don't use fancy single or double quotes for string literals. Don't user normal double quotes either, they're for identifiers. Just normal 7 bit ASCII single quotes: '. So location = 'los angeles' and name = 'tacos los guichos'... Hint: Always write your code in a plain text editor, never use any rich text editor or any office text program like Microsoft Word or LibreOffice Writer to do so. Commented Mar 22, 2021 at 2:33
  • Makes so much sense! That is definitely key knowledge. thanks :) Commented Mar 30, 2021 at 10:19

1 Answer 1

2

In Postgres (as in standard SQL):
'Strings' are quoted with single quotes.
"Identifiers" can be quoted with double quotes.

Typographic quotes like in ”los angeles” or ‘tacos los guichos’ don't do anything useful.

See:

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. Very useful to know

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.