SHARE
TWEET

Untitled

a guest Jul 17th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. id | username | ... |
  2. ----------------------
  3.  1  | name1cat | ... |
  4.  2  |    cat   | ... |
  5.  3  |   name4  | ... |
  6.  4  |   test   | ... |
  7.      
  8. id | product_name | user_id |  end_date  | active |
  9. ---------------------------------------------------
  10.  1 |    good cat  |    1    | 2019-07-15 |   t    |
  11.  2 |    good dog  |    4    | 2019-07-20 |   t    |
  12.  3 |      cat     |    3    | 2019-07-20 |   t    |
  13.  4 |   good phone |    2    | 2019-07-20 |   f    |
  14.      
  15. SELECT P.PRODUCT_ID, P.PRODUCT_NAME, U.USER_ID
  16. FROM PRODUCTS AS P
  17. LEFT JOIN USERS AS U ON (U.USER_ID = P.USER_ID)  
  18. WHERE
  19. P.ACTIVE = TRUE
  20. AND P.END_DATE >= NOW()
  21. AND LOWER(P.PRODUCT_NAME) LIKE LOWER('%cat%') OR LOWER(U.USERNAME) LIKE LOWER('%cat%')                          
  22. GROUP BY P.PRODUCT_ID, U.USER_ID
  23.      
  24. id | product_name | user_id | PRODUCT_NAME |  end_date  | active |
  25. ------------------------------------------------------------------
  26.  1 |      cat     |    3    |     name4    | 2019-07-20 |   t    |
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top