How to do a count on a union query

前端 未结 6 1060
谎友^
谎友^ 2020-12-28 12:32

I have the following query:

select distinct profile_id from userprofile_...

union

select distinct profile_id from productions_...

How wou

6条回答
  •  [愿得一人]
    2020-12-28 13:10

    As omg ponies has already pointed out that there is no use of using distinct with UNION, you can use UNION ALL in your case.....

    SELECT COUNT(*) 
    FROM 
    ( 
    select distinct profile_id from userprofile_...
    union all
    select distinct profile_id from productions_...
    ) AS t1 
    

提交回复
热议问题