Create field in MySQL SELECT

If I have a table containing Field1 and Field2, can I generate a new field in the select statement? For example, a regular query:

SELECT Field1, Field2 FROM Table 

And I also want to create Field3 and return it to the result set ... something in accordance with this would be ideal:

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

Is this even possible?

+3
source share
2 answers
SELECT Field1, Field2, 'Value' Field3 FROM Table

or for clarity

SELECT Field1, Field2, 'Value' AS Field3 FROM Table
+11
source

Yes - it is very possible, in fact you almost got it! Try:

SELECT Field1, Field2, 'Value' AS `Field3` FROM Table
+5
source

Source: https://habr.com/ru/post/1696630/


All Articles