79371154

Date: 2025-01-20 11:29:43
Score: 1
Natty:
Report link

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.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Manraj Patel