Right now I'm in a trouble and donot know how to solve it.
Declare @brand_id varchar(50) ='brand1, brand2'
SELECT related_brand_id FROM dbo.Category
=> result: Row 1: "brand1, brand3, brand5"
Row 2: "brand3, brand5"
Row 3: "brand5"
Row 4: "brand2, brand5"
...
So, how can I select all rows in table Category with param @brand_id contain IN related_brand_id?
My expectation result:
Row 1: "brand1, brand3, brand5"
Row 4: "brand2"
...
In SQL Server 2016 and above, you can use
string_split
:Output:
db<>fiddle here