Skip to content

Instantly share code, notes, and snippets.

@icholy
Created November 5, 2014 18:11
Show Gist options
  • Save icholy/ea05b5efde16e6e0baeb to your computer and use it in GitHub Desktop.
Save icholy/ea05b5efde16e6e0baeb to your computer and use it in GitHub Desktop.

There is a 1-to-1 relationship between ids and items.

with item_ids as (
	      select 1 as id
	union select 2
	union select 3
	union select 4
	union select 5
	union select 6
)
select items.*
from item_ids
left join items on items.id = item_ids.id
select *
from items
where id in (1, 2, 3, 4, 5, 6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment