开发者

Select from table with multiple values

开发者 https://www.devze.com 2023-03-31 12:30 出处:网络
My query is SELECT* FROMtblalumni_member WHEREusername IN ( SELECT* FROM开发者_运维技巧Split(\'ramesh,sagar,pravin\', \',\') )

My query is

SELECT  *
FROM    tblalumni_member
WHERE   username IN ( SELECT    *
                      FROM      开发者_运维技巧Split('ramesh,sagar,pravin', ',') )
        AND Is_Approved = 1

and username field contains multiple values separated by comma. Like ramesh,sachin,pravin.

It should give all rows if any of get matched in selected result.

Can you please help me?


In case of SQL Server perhaps something like

SELECT *
FROM   tblalumni_member m
WHERE  Is_Approved = 1 AND
       EXISTS(
            SELECT * FROM Split(m.username, ',')
          INTERSECT
            SELECT * FROM Split('ramesh,sagar,pravin', ',')
       )
0

精彩评论

暂无评论...
验证码 换一张
取 消