Guest User

Untitled

a guest
Feb 13th, 2018
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. Table1
  2. id date email cId
  3. 1 2013-08-28 12:21:39 t@gmail.com 12345
  4. 2 2013-07-27 10:15:18 k@gmail.com 12345
  5. 3 2018-02-13 09:41:43 a@gmail.com 12345
  6. 4 2018-02-02 10:14:42 n@gmail.com 45678
  7. 5 2017-11-16 10:16:51 l@gmail.com 45678
  8.  
  9. Table2
  10. id status
  11. 12345 1
  12. 45678 1
  13. 56789 0
  14.  
  15. select c.id 'table 2 Id', DATE_FORMAT(Max(u.date),'%Y-%m-%dT%TZ') 'Date', u.email 'User' from table2 c
  16. LEFT JOIN table1 u ON u.cId = c.id where c.status = 1 group by c.id order by c.id;
  17.  
  18. table 2 Id Date USER
  19. 12345 2018-02-13 09:41:43 t@gmail.com
Add Comment
Please, Sign In to add comment