André P. Posted December 13, 2015 Report Posted December 13, 2015 Hi, It would take me an hour or so to create a working SQL query, so I tought I better ask this here. Can you help me out? I am trying to get all email addresses of active users of the group "vServers". Thank you guys! André Quote
0 Tyson Posted December 15, 2015 Report Posted December 15, 2015 This will get you more info for context, or you can remove the fields just for the email addresses: SELECT `contacts`.`client_id`, `contacts`.`id` AS `contact_id`, `contacts`.`first_name`, `contacts`.`last_name`, `contacts`.`email`, `services`.`status`, `services`.`date_canceled`, COUNT(`services`.`id`) AS `number_of_services` FROM `contacts` INNER JOIN `services` ON `services`.`client_id` = `contacts`.`client_id` WHERE `services`.`status` = 'active' AND `services`.`package_group_id` = '1' GROUP BY `contacts`.`id` ORDER BY `contacts`.`client_id`, `contacts`.`id` André P. and Michael 2 Quote
0 André P. Posted December 15, 2015 Author Report Posted December 15, 2015 Sharing is caring, folks! select distinct email from contacts where client_id in (select client_id from services where package_group_id='n' and status='active'); Where n is your package group # of service XY. I think it would be even better to also get status "cancelled" and check if the date is in the future. Michael 1 Quote
Question
André P.
Hi,
It would take me an hour or so to create a working SQL query, so I tought I better ask this here.
Can you help me out? I am trying to get all email addresses of active users of the group "vServers".
Thank you guys!
André
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.