Joining a table based on comma separated values

前端 未结 4 1785
时光取名叫无心
时光取名叫无心 2020-12-06 14:52

How can I join two tables, where one of the tables has multiple comma separated values in one column that reference an id in another column?

1st

4条回答
  •  一个人的身影
    2020-12-06 15:30

    Maybe this uglyness, I have not checked results:

    select names.name, courses.course_name
    from names inner join courses
        on ',' + names.course_ids + ',' like '%,' + cast(courses.course_id as nvarchar(20)) + ',%'
    

提交回复
热议问题