假设两张表 A与BA
ID NAME
B
ID VALUEselect a.id,a.name,b.value from a,b and a.id=b.id
现在是想显示以A表为主的数据,也就是说B表未必会有A的ID/VALUE,当查询时如果没有VALUE的就用NULL代替
ID NAME
B
ID VALUEselect a.id,a.name,b.value from a,b and a.id=b.id
现在是想显示以A表为主的数据,也就是说B表未必会有A的ID/VALUE,当查询时如果没有VALUE的就用NULL代替
from a,b and a.id=b.id(+);
from a left join b on (a.id=b.id)
select a.id,a.name,b.value from a,b and a.id=b.id(+)或者用left join.
但ORACLE中建议用(+),简洁方便.