nem.ec

Programming Information Security Recipes Personal Code Snippets

Select an inline table of data

SELECT * FROM ( 
   VALUES(1, 'red'), 
         (2, 'orange'), 
         (5, 'yellow'), 
         (10, 'green'), 
         (11, 'blue'), 
         (12, 'indigo'), 
         (20, 'violet')) 
   AS Colors(Id, Value) 

Using an inline table in a join:

SELECT v.valueId, m.name  
FROM (VALUES (1), (2), (3), (4), (5)) v(valueId) 
LEFT JOIN otherTable m 
ON m.id = v.valueId