mysql左连接查询时多条件的注意事项

时间:2023-02-13 13:57:15

mysql左连接查询时多条件的注意事项

1、返回左表所有数据

select *
from oilDaily left outer join wellInfo
on oilDaily.wellId=wellInfo.wellId and  oilDaily.wellId='庆11-001'
group by wellId,oilTime
order by wellId asc,oilTime asc;

2、返回符合条件的数据

select *
from oilDaily left outer join wellInfo
on oilDaily.wellId=wellInfo.wellId
where oilDaily.wellId='庆11-001'
group by wellId,oilTime
order by wellId asc,oilTime asc;