Search code examples
mysqlselectvirtual

SQL SELECT one virtual Colum with more values


I want to creat a virtual Column to do some special operation in MySQL... So i need to creat a "virtual Column" with some static values. But i dont't know how...

eg. SELECT 3 as number shows Column "number" with the value 3. SELECT 3, 4, 67, 9 shows four different Columns with only one value.

i tried it with some combination of both, like: SELECT 3, (SELECT 5), (SELECT 4) or

SELECT 3 as a, 4 as a, 67 as a

or SELECT 3 && 6 && 9 && 3 or

SELECT 3 || 6 || 9 || 3

How my query have to looks like to get only one Column with more values like on a simple statement???

Thanks guys


Solution

  • You need union query to show multiple values within a single alias

    SELECT 3 as col
    UNION ALL
    SELECT 4 as col
    UNION ALL
    SELECT 67 as col
    

    DEMO