sql根据一个表查询的数据作为条件查询另一个表

代码格式如下:

select *  from BillConsume where obId in (select obId from OpenBills where clearTheMarket is null or clearTheMarket=0)

  要注意的是:in后面的查询语句必须是查询一个字段跟前面的表相对应的。比如要根据订单号orderID,OpenBills 这个表就需要查询到orderID这个字段,BillConsume这个表的条件就要判断orderID

posted @ 2020-12-05 15:44  骇客黑界  阅读(11812)  评论(0编辑  收藏  举报