1

Is there some alternative in MYSQL for Postgres VALUES syntax:

select * 
from (values('1'), ('2')) as f;
Paul White
  • 83,961
  • 28
  • 402
  • 634
BBaron
  • 39
  • 1
  • 3
  • I need join data from redis with table in MySQL. In postgresql i can do that with this syntax. I dont want create temp table in mysql and then join it. – BBaron Apr 25 '18 at 19:36
  • In other words, you need a result set composed of literal values that your program retrieves from Redis. – mustaccio Apr 25 '18 at 20:04

1 Answers1

3

MySQL (as well as Postgres) allows you to select from nothing, so you can do this:

select * 
from (
  select 1 as some_value
  union all
  select 2
  -- etc.
) t

Since you intend to join this set to a table, you'll need to provide column aliases that you can reference later at least in the first inner select.

mustaccio
  • 25,896
  • 22
  • 57
  • 72