tags:

views:

519

answers:

4

If I've got a table containing Field1 and Field2 can I generate a new field in the select statement? For example, a normal query would be:

SELECT Field1, Field2 FROM Table

And I want to also create Field3 and have that returned in the resultset... something along the lines of this would be ideal:

SELECT Field1, Field2, Field3 = 'Value' FROM Table

Is this possible at all?

+10  A: 
SELECT Field1, Field2, 'Value' Field3 FROM Table

or for clarity

SELECT Field1, Field2, 'Value' AS Field3 FROM Table
Josh
+5  A: 

Yes - it's very possible, in fact you almost had it! Try:

SELECT Field1, Field2, 'Value' AS `Field3` FROM Table
Whisk
A: 

Many thanks. :)

James Inman
A: 

Thanks a lot. This answer "SELECT Field1, Field2, 'Value' AS Field3 FROM Table" was helpful to me.