php - How to join two tables without duplicates? -


i have in table looks this:

id_in  | date_in    -------|-------------------------- 1      | 2016-04-29 02:00:00 

and out table looks this:

id_out    |  date_out ----------|-------------------------- 1         | 2016-04-29 03:00:00 2         | 2016-04-29 04:00:00 3         | 2016-04-29 05:00:00 

i want write query output looks this:

id_in | date_in                     | id_out                     | date_out ------|---------------------------- |----------------------------|--------------------------- 1     | 2016-04-29 02:00:00         | 1                          |2016-04-29 03:00:00 null  |  null                       | 2                          |2016-04-29 04:00:00 null  |  null                       | 3                          |2016-04-29 05:00:00 

you can left join:

select i.id_in, i.date_in, o.id_out, o.date_out outtable o left join      intable      on o.id_in = i.id_out; 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -