I want to add a column in a query that does not exist in a table and return it as a result. So lets say TABLE_TEST has column A, B and I want to return values for A, B and C. I am trying to do
SELECT A, B, C=3 FROM TABLE_TEST
or
SELECT *, C=3 FROM TABLE_TEST
Can this be done in MySQL, Postgr开发者_运维技巧esel or MSSQL?
Yes, sure:
select a, b, 3 as c from table_test
That's it. It works on three db engines you've mentioned.
You should use:
SELECT A,B, 3 AS C FROM TABLE_TEST
you can use as
Select a,b, 3 as c from table
This is known as alias
精彩评论