sql - 如何从不同的表中查询 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'
谢谢你!
解决方案
如果我的理解是正确的,那么试试这个代码:
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'
推荐阅读
- c - 为什么我的代码块在 main() 中起作用,但在它自己的函数中不起作用?
- laravel - 我正在使用 laravel 5.6 日志,我正在尝试存储用户登录数据
- ios - 如何在这个项目中实现新的 .mlmodel
- angular - 如何在按钮单击时在父 div 中附加和删除子 div?
- javascript - 如何自动增加在单击按钮时动态添加的输入字段(类型=文本)中的值?
- javascript - 如何在不影响角度原始数据的情况下从模板修改数组中的数据
- apache-kafka - 如何优化聚合以便首先完成每个消费者的聚合?
- java - 迷宫的邻接矩阵
- javascript - 1 个按钮切换 3 种排序变化
- python - STM32 - 无法从pyserial打开串口,但可以从ST-Link