André P. Posted December 13, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
0 Tyson Posted December 15, 2015 Report Share 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 Link to comment Share on other sites More sharing options...
0 André P. Posted December 15, 2015 Author Report Share 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 Link to comment Share on other sites More sharing options...
0 André P. Posted December 18, 2015 Author Report Share Posted December 18, 2015 Thank you! Quote Link to comment Share on other sites More sharing options...
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é
Link to comment
Share on other sites
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.