If using a table is restricted then this can be achieved using STRING_SPLIT function.
(Following code is for MS SQL)
declare @ids varchar(50) = '1,3,10'
SELECT
t.value as Id, X.Name
FROM
STRING_SPLIT(@ids, ',') t
LEFT JOIN X on t.[value] = X.Id
This will provide the expected output.