0

I have a Postgres db. The tables are each in separate namespaces, which are named using two character state codes. The problem is this: for the state Indiana, the state code is "in". I am trying to execute this query:

SELECT city_name
FROM in.places

But I keep getting an error complaining about the 'in', presumably because there is a reserved keyword IN. How can I query the tables inside the 'in' namespace?

a_horse_with_no_name
  • 497,550
  • 91
  • 775
  • 843
Blighty
  • 189
  • 2
  • 17
  • `"IN"`, but I'd instead chose some other name. https://en.wikipedia.org/wiki/SQL_reserved_words – jarlh Jul 19 '21 at 12:43
  • If you are stuck with this awful naming convention (the data should all be in one table), then use either `"in".places` or `"in.place"` -- whichever is appropriate. – Gordon Linoff Jul 19 '21 at 12:45
  • Mandatory read [Identifiers and Key Words](https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS) in the Postgres manual – a_horse_with_no_name Jul 19 '21 at 14:01

0 Answers0