user1686342
user1686342

Reputation: 1345

Getting error when running select where to='...'

Trying to run a psql query of the form

Select * from x where to='...'

Is 'to' a reserved word? Doesn't seem to like it.

Upvotes: 1

Views: 44

Answers (2)

Mansoor
Mansoor

Reputation: 4192

Select * from x where [to] ='...'

Upvotes: -1

Mureinik
Mureinik

Reputation: 311228

"to" is indeed a reserved word in PostgreSQL, as it is in the ANSI standards of SQL-92, SQL:1999 and SQL:2003.

You can escape it by using double-quotes (") if you absolutely have to, although I recommend you just find a non-reserved name for your column:

SELECT *
FROM   x
WHERE  "to" = 3
-- Here^--^

Upvotes: 2

Related Questions