Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a command for "AS" in postgres?

I'm wondering if there is a command like AS for postgres. Does anyone know if postges has this ability? I've tried to google it but it's a very difficult question to google :P I want to make a select statement and store it as a new table name. I want to say something like:

select subj, user as 'new' from table_name;

like image 682
locoboy Avatar asked Dec 27 '22 15:12

locoboy


1 Answers

Yes. It's a reserved SQL key word in PostgreSQL. See Table C-1 at the linked documentation page.

It's typically used with column labels.

The AS keyword is optional, but only if the new column name does not match any PostgreSQL keyword (see Appendix C).

like image 137
csano Avatar answered Dec 30 '22 04:12

csano