联合#结果在一起

时间:2018-09-08 04:19:01

标签: mysql sql

我想显示80,000个电影的结果和80,000个电视的结果,因此合计160,000个结果。这是我当前拥有的查询:

select country_of_tld, content_type_id, provider_id, name
from main_iteminstance where content_type_id='movie'
limit 80000
  union
select country_of_tld, content_type_id, provider_id, name
from main_iteminstance where content_type_id='tv season'
limit 80000

但是,这只能给我80k的结果,而不是160k。我将如何获得16万个结果,8万个动作和8万个电视季?

1 个答案:

答案 0 :(得分:1)

尝试添加括号

(select country_of_tld, content_type_id, provider_id, name
from main_iteminstance where content_type_id='movie'
limit 80000)
union all
(select country_of_tld, content_type_id, provider_id, name
from main_iteminstance where content_type_id='tv season'
limit 80000)