daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest May 17th, 2018 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT * FROM categories
  2. LEFT JOIN subscriptions
  3. ON subscriptions.category_id = categories.category_id
  4. WHERE
  5.  IF EXISTS(subscriptions.is_enable)
  6.   categories.type = 'premium' AND
  7.   subscriptions.is_enable = 1
  8. ELSE
  9.   categories.type = 'premium' AND
  10.    
  11. SELECT * FROM categories
  12. LEFT JOIN subscriptions
  13. ON subscriptions.category_id = categories.category_id
  14. WHERE
  15.   (EXISTS(subscriptions.is_enable) AND
  16.   categories.type = 'premium' AND
  17.   subscriptions.is_enable = 1)
  18. OR
  19.   (categories.type = 'premium' AND...)
  20.    
  21. SELECT * FROM categories
  22. LEFT JOIN subscriptions
  23. ON subscriptions.category_id = categories.category_id
  24. WHERE (subscriptions.is_enable IS NULL OR subscriptions.is_enable = 1)
  25.   AND categories.type = 'premium'
RAW Paste Data
Top