首页 > 解决方案 > 如何从不同的表中查询 2 个不同的“WHERE”

问题描述

151 - Transaction table for Received
202 - Transaction table for Put-away

hu_ID - Carton 
Employee_ID - Employee Name
Control_number_2 - PO#
Location_ID_2 - Location

仅供参考 日期将出现

简而言之,我需要知道 PO# 的存放位置。

查询收货:

Select hu_ID, Control_number_2
from t_tran_log ttl WITH (NOLOCK)
WHERE tran_type = **'151'**
AND ttl.end_tran_date BETWEEN '2019-09-01' and '2019-09-02'

上架查询:

Select hu_ID, Control_number_2, location_ID_2
from t_tran_log ttl WITH (NOLOCK)
WHERE tran_type = **'202'**
AND ttl.end_tran_date BETWEEN '2019-09-01' and '2019-09-02'

谢谢你!

标签: sqloracle

解决方案


如果我的理解是正确的,那么试试这个代码:

Select hu_ID, Control_number_2, location_ID_2
from t_tran_log ttl WITH (NOLOCK)
WHERE tran_type = **'202'** OR tran_type = **'151'**
AND ttl.end_tran_date BETWEEN '2019-09-01' and '2019-09-02'

推荐阅读