I have the following query:
select distinct profile_id from userprofile_... union select distinct profile_id from productions_...
How wou
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