nitaish Posted August 17, 2020 Share Posted August 17, 2020 I want to export list of clients in whmcs who has till now purchased only one service both active as well as inactive. Can anyone help me with the SQL query? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 17, 2020 Share Posted August 17, 2020 SELECT t1.userid, CONCAT(t2.firstname, " ", t2.lastname) AS clientname FROM tblhosting AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id GROUP BY t1.userid HAVING COUNT(*) = '1' 1 Quote Link to comment Share on other sites More sharing options...
nitaish Posted August 17, 2020 Author Share Posted August 17, 2020 Can you also provide query which also gives the list of services the client has purchased till now? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 17, 2020 Share Posted August 17, 2020 SELECT t1.userid, CONCAT(t2.firstname, " ", t2.lastname) AS clientname, t1.id AS pid, CONCAT(t4.name, " > ", t3.name) AS productName FROM tblhosting AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id LEFT JOIN tblproducts AS t3 ON t1.packageid = t3.id LEFT JOIN tblproductgroups AS t4 ON t3.gid = t4.id GROUP BY t1.userid HAVING COUNT(*) = '1' 1 Quote Link to comment Share on other sites More sharing options...
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.