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.

Emma N
  • 1
  • 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. – sticky bit Mar 22 '21 at 02:33
  • Makes so much sense! That is definitely key knowledge. thanks :) – Emma N Mar 30 '21 at 10:19

1 Answers1

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:

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228