Mysql IN Subquery具有附加值

时间:2013-09-18 13:53:12

标签: mysql sql

我正在尝试使用IN选择行但我想在IN语句中添加另一个值。

实施例

SELECT title FROM film WHERE film_id IN (SELECT film_id FROM film_actor)

好的...得到结果......没问题..

SELECT title FROM film WHERE film_id IN ((SELECT film_id FROM film_actor), 130)

如何添加其他值(130),如上面的查询?

韩国社交协会。 阿德

2 个答案:

答案 0 :(得分:3)

尝试使用union all,如下所示

SELECT title FROM film WHERE film_id IN (SELECT film_id FROM film_actor
                                         union all
                                         SELECT 130)

答案 1 :(得分:2)

如何使用OR

WHERE film_id IN (SELECT film_id FROM film_actor) OR
      film_id = 130 

如果您要包含多个值,

WHERE film_id IN (SELECT film_id FROM film_actor) OR
      film_id IN (120, 130, 140, .....)