SQL Server store multiple values in sql variable

后端 未结 6 900
春和景丽
春和景丽 2020-12-29 15:02

I have the following query:

select * 
from cars 
where make in (\'BMW\', \'Toyota\', \'Nissan\')

What I want to do is store the where param

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 15:16

    you can use JOIN statement.

    SELECT distinct c.*
    FROM cars c
    JOIN carsfrosale s
    ON s.id = c.fk_s
    

    If you want filter your list of carsforsale you can add

    WHERE s.id in (....)
    

提交回复
热议问题