tags:

views:

27

answers:

1

Does anyone know how can I join 2 table with 2 join condition?

Exmaple:

table 1
date        name     
2010-01-01  Ken      
2010-01-01  Alvin    
2010-01-03  Alvin    
2010-01-04  Ken      
2010-01-07  Amy 




table 2
date        name     count
2010-01-01  Ken      5
2010-01-01  Alvin    4
2010-01-04  Ken      1
2010-01-03  Alvin    0

How can I join table 1 and table 2 together when: table1 date = table2 date AND table1 name = table2 name

+2  A: 
SELECT 
    T1.*, T2.*
FROM 
    T1 JOIN T2 ON T1.date = T2.date AND t1.name = t2.name
mikerobi