Reputation: 1002
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?
Upvotes: 4
Views: 2051
Reputation: 3417
Yes - it's very possible, in fact you almost had it! Try:
SELECT Field1, Field2, 'Value' AS `Field3` FROM Table
Upvotes: 5
Reputation: 8016
SELECT Field1, Field2, 'Value' Field3 FROM Table
or for clarity
SELECT Field1, Field2, 'Value' AS Field3 FROM Table
Upvotes: 12