Find primary key from one table in comma separated list

后端 未结 4 1174
情话喂你
情话喂你 2020-12-12 06:29

I\'ve been given the task at work of creating a report based on a very poorly designed table structure.

Consider the following two tables. They contain techniques t

4条回答
  •  误落风尘
    2020-12-12 06:42

    The first comment under the question provided the link to the answer. Here's what I ended up going with:

    WHERE
       p.Technique LIKE '%,29,%' --middle
          OR
       p.Technique LIKE '29,%' --start
          OR
       p.Technique LIKE '%,29' --end
          OR 
       p.Technique =  '29' --single (good point by Cheran S in comment)
    

    At initial glance I thought it wouldn't work, but clever use of % made it not match ids like 129, etc.

提交回复
热议问题