Need help in dynamic query with IN Clause

前端 未结 3 879
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 07:17

I have 1 Table which is named as ProductMaster.Another Table which is VendorMaster. Now i want to find all the products from specified Vendormaster.

So i want to use

3条回答
  •  长情又很酷
    2020-12-12 07:54

    You could just use

    SELECT * FROM ProductMaster WHERE VendorId IN (
      SELECT DISTINCT VendorId FROM VendorMaster 
      WHERE PATINDEX('%'+VendorName+'%',@VendorNameCommaSeparated)>0
    )
    

提交回复
热议问题