Miss Song
Miss Song

Reputation: 41

How to split a comma-separated value

I have table myTable with field like this

tranType              Source
-------------------------------------
RC,RD,RF,RR           PB,CM

I want to create stored procedure that use value of tranType and Source as condition in my query

select * 
from myTable
where Source = @valSource  -- PB (check for each value from Source)
  AND tranType = @valTrantype  -- RC(check for each value from tranType)

it will check all of the value in that field

Upvotes: 0

Views: 46

Answers (1)

Kartik Shah
Kartik Shah

Reputation: 107

Please check with following:

select * from myTable 

where find_in_set(@valSource,Source) 

AND find_in_set(@valtranType,tranType)

Upvotes: 1

Related Questions