php - Get most recent date from two tables -


i have 2 tables

table1:

    ______id_______|_______serials______|____date_____|__include__           20       |         1123       |   22-05-2014|    yes           20       |         2231       |   12-06-2013|    no           21       |         3213       |   24-01-2014|    yes           22       |         5123       |   27-10-2012|    yes           20       |         1213       |   02-03-2014|    yes  

table 2:

   ______id_______|______serials_______|____date_____|__rma__           1       |         1123       |   01-05-2014|   1           2       |         2231       |   22-06-2014|   7           3       |         3353       |   20-01-2013|   5           4       |         1213       |   27-03-2014|   2           5       |         5123       |   06-03-2014|   9 

i need data of matched serials 2 tables , need pull recent date 2 tables. how expecting output

_____id_______|_______serials______|__recentdate_|__include__|__id__|__serial__|__rma__      20       |         1123       |   22-05-2014|    yes    |  1   |  1123    |   1      20       |         2231       |   22-06-2014|    no     |  2   |  2231    |   7      20       |         1213       |   27-03-2014|    yes    |  4   |  1213    |   2      22       |         5123       |   06-03-2014|    yes    |  5   |  5123    |   9 

can me please.

select  t1.id, t1.serials,         case when t1.date > t2.date t1.date else t2.date end recentdate,         t1.include, t2.id, t2.serials, t2.rma    table1 t1 join    table2 t2 on      t2.serials = t1.serials 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -