festinko

Untitled

Sep 16th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.63 KB | None | 0 0
  1. /*Users with payment for SMS / call notification credits & not active SMS / call alert contact*/
  2.  
  3. SELECT
  4.     p.userID,
  5.     u.userEmail,
  6.     userNewsletter,
  7.     userSMSRefill
  8.  
  9. FROM
  10.     payments p
  11.  
  12. LEFT JOIN
  13.     users u
  14.  
  15.     ON p.userID = u.userID
  16.  
  17. WHERE
  18. paymentPeriod = 0
  19. AND (userSMSRefill = 0  OR userSMSRefill IS NULL)
  20. AND u.userID IS NOT NULL
  21. AND p.userID NOT IN (
  22. /*Users with active SMS / Voice call alert contact*/
  23.        
  24.     SELECT
  25.         userID
  26.     FROM
  27.         alertcontacts
  28.                    
  29.     WHERE
  30.         alertContactType IN (8,14)
  31.         AND alertContactStatus = 2
  32.                    
  33.     GROUP BY
  34.     userID
  35. )
  36.  
  37. GROUP BY
  38.     p.userID
  39.  
  40. ORDER BY
  41.     userNewsletter,
  42.     userSMSRefill
  43.  
Add Comment
Please, Sign In to add comment