Reputation: 55
Below is my query :
SELECT DISTINCT(di.device_token) FROM device_info di WHERE di.IMEI_number IN (SELECT DISTINCT(ud.device_id) FROM user_details ud WHERE ud.device_OS='android')
This query takes hell lot of time to execute because of the IN clause. I found using joins is the best way. Yet, I am unable to figure how to use DISTINCT
on both the tables.
Any suggestion is welcome.
Upvotes: 1
Views: 106
Reputation: 2401
Try the below query -
SELECT distinct (di.device_token) FROM device_info di,user_details
where di.IMEI_number in (user_details.ud.device_id)
and ud.device_OS='android';
Upvotes: 1
Reputation: 319
Try this:
SELECT di.device_token FROM device_info di
JOIN user_details ON user_details.ud.device_id = di.IMEI_number
WHERE ud.device_OS='android'
GROUP BY di.device_token
Upvotes: 0