I'm trying to select rows using IN but I want to add inside IN statement another value.
我尝试使用IN来选择行但是我想在语句中添加另一个值。
Example
例子
SELECT title FROM film WHERE film_id IN (SELECT film_id FROM film_actor)
Ok... Get result..no problem..
好吧……得到的结果. .没有问题. .
SELECT title FROM film WHERE film_id IN ((SELECT film_id FROM film_actor), 130)
How can add another value (130) like the query above?
如何像上面的查询一样添加另一个值(130)?
Tks. Adriano
谢谢大家。阿德里亚诺
2 个解决方案
#1
3
Try to use union all
as below
试着使用下面的union allas
SELECT title FROM film WHERE film_id IN (SELECT film_id FROM film_actor
union all
SELECT 130)
#2
2
how about using OR
?
使用或怎么样?
WHERE film_id IN (SELECT film_id FROM film_actor) OR
film_id = 130
if you have multiple values to be included,
如果要包含多个值,
WHERE film_id IN (SELECT film_id FROM film_actor) OR
film_id IN (120, 130, 140, .....)
#1
3
Try to use union all
as below
试着使用下面的union allas
SELECT title FROM film WHERE film_id IN (SELECT film_id FROM film_actor
union all
SELECT 130)
#2
2
how about using OR
?
使用或怎么样?
WHERE film_id IN (SELECT film_id FROM film_actor) OR
film_id = 130
if you have multiple values to be included,
如果要包含多个值,
WHERE film_id IN (SELECT film_id FROM film_actor) OR
film_id IN (120, 130, 140, .....)