Need this equivalent outcome on PostgreSQL on this MySQL query.
select id, 'ID1' from supportContacts
Idea is to Join a Column with table name and row values equals to ID1.
Executing the same query on PostgreSQL gives the desired row values but gives ?column? uknown as column name.
Which PostgreSQL query will give the exact output?
Add a column alias to assign a name of your choosing. Else the system applies defaults.
To assign a type, use an explicit cast. I cast to
texthere:Or use the SQL standard
cast()to make it portable:For portability, make sure that MySQL runs with
SET sql_mode = 'ANSI'.Also, unquoted CaMeL-case names like
supportContactsare cast to lower case in PostgreSQL. Use"supportContacts"orsupportcontactsdepending on the actual table name.Start by reading the excellent manual here for basics about identifiers.