Can someone tell me why this works in MySQL but not PostgreSQL?
select "hi" as ham, 1 as eggs
I'm trying to union a query with some hard-coded values.
Postgres says "ERROR: column "hi" does not exist Position: 8"
MySQL says the right thing.
you need to change the " to ' double qoute to single qoute in postgress
select 'hi' as ham, 1 as eggs
If you want to let hi be row value you need to use single-qoute otherwise PostgreSQL DB Engine will take it as a column.
This sample ORDER is a keyword but I can use double-qoute to escape the keyword as column name, although I didn't encourage use keyword as a column name.
CREATE TABLE T("ORDER" INT);
INSERT INTO T VALUES (1);
SELECT "ORDER"
FROM T
so you might use like this.
select 'hi' as ham, 1 as eggs
single quoteinsteaddouble quote..Postgresqlknowhias column not string..