简体   繁体   中英

how to check multiple values in a single comma seperated column

I am trying to execute a query in c#,the query as

select Id from employee where name in (@name)

i am try to passing 3 cases

1.@name='sa'
2.@name='as,ab'
3.@name='ad'

and the output am expecting

1.id=1

2.id=2

3.id=3

my table employee value contains ,

在此处输入图片说明

First create user defined split function in DB using this link Then Apply to your table. it would very easy for you.

How about the assigning the variable

@name='%sa%'

and then using this below query

 select * from employee where Names LIKE (@name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM