Joining a list of values with table rows in sql
06 Jun 2020
sqlRepost of StackOverflow answer
In Microsoft SQL Server 2008 or later you can use Table Value Constructor
SELECT v.valueId, m.name
FROM (VALUES (1), (2), (3), (4), (5)) v(valueId)
LEFT JOIN otherTable m ON m.id = v.valueId
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.