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