select from values in mysql select from values in mysql postgresql postgresql

select from values in mysql


From the link you provided :

VALUES (1, 'one'), (2, 'two'), (3, 'three');
This will return a table of two columns and three rows. It's effectively equivalent to:
SELECT 1 AS column1, 'one' AS column2
UNION ALL
SELECT 2, 'two'
UNION ALL
SELECT 3, 'three';

So you need

select * from table1,(   SELECT 1 AS val   UNION ALL   SELECT 2   UNION ALL    SELECT 3 )b


In MySQL 8.0.19, this syntax is supported. please refer to this official link

mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8);+----------+----------+----------+| column_0 | column_1 | column_2 |+----------+----------+----------+|        1 |       -2 |        3 ||        5 |        7 |        9 ||        4 |        6 |        8 |+----------+----------+----------+


This is another way to get around the lack of WITH support in MySQL:

create temporary table tmp (c int);insert into tmp (c)values (1), (2), (3);select * from tmp;