left join

--已经上线的,但是没有下线的工位。序号不能够重复
select DISTINCT s.seqplanno, s.*
  from seqplan s
  left join prodplan p
    on s.seqplanno = p.seqplanno
 where onmark = '*'
   and offmark is null;  --注意下线不能够使用!=这样为空的,即没有下线的数据是查询不出来的。

关于left join:http://www.w3school.com.cn/sql/sql_join_left.asp

原文地址:https://www.cnblogs.com/zerocc/p/2116621.html