2012-12-21 133 views
0

我有两个表设备和产品。设备表具有列标识和设备。 和产品表有列id和产品。如何结合两个表来获得所需的结果

设备表是

id  device 

1  a     
2  b     
3  b   

产物表是

id  product 

1  x  
2  y   
3  z  
4  s 

我需要的结果作为

id  device 

    1  a  
    2  b   
    3  b  
    4  null 

回答

0

试试这个

select p.id,d.device from products p outer join device d 
on d.id=p.id 
0

你应该尝试这个连接

select p.id,d.Device 
     from tblDevice d 
     right join tblProduct p 
     on d.id=p.id 
相关问题