mysql左连接左表左边数据为null

图片说明
左表数据10000条,右表数据2500条,左表datee对应右表唯一datee,通过左连接获取对应orderid的year;左连接后为null。

select stock.orderid,sdate.year from stock left join sdate on stock.datee=sdate.datee limit 10;

结果

+---------+------+
| orderid | year |
+---------+------+
| 009999  | 2017 |
| 000000  | NULL |
| 000001  | NULL |
| 000002  | NULL |
| 000003  | NULL |
| 000004  | NULL |
| 000005  | NULL |
| 000006  | NULL |
| 000007  | NULL |
| 000008  | NULL |
+---------+------+

说明stock与sdate对应的列year是null

select a.orderid,b.year from stock a,sdate b where a.datee=b.datee limit 10;这样试试,应该可以