Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

column alias as NUMBER in PostgreSQL

Tags:

postgresql

I am using a number as alias in select query in PostgreSQL

Select json->>'1' as 1 from myTable

It shows an error

"error in query near 1".

It works fine if we dont use number (eg. json->>'1' as data )

like image 531
Vishu238 Avatar asked Feb 05 '23 05:02

Vishu238


1 Answers

Double quotes for identifiers:

Select json->>'1' as "1" 
from myTable

https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

like image 173
Clodoaldo Neto Avatar answered Apr 27 '23 10:04

Clodoaldo Neto