加入两个表以获得确切的日期
Joining two tables to get the exact date
我有两个 table,
第一 table --> 贷款,
列 --> pos_num , pos_type
第 2 table --> 付款,
列 --> pos_num , pos_type , 日期
我想从贷款中提取 pos_num , pos_type 值并放在下面的查询中
select count(1) from payment where pos_num = <value extracted from loans> and pos_type = <value extracted from loans> and date = <?>
我如何加入贷款 table 和付款 table 以获得我们应该在付款 table 中为 pos_num 获得相同数据的日期,pos_type 我们从贷款中得到 table
您可以使用 JOIN 语句获取值,例如:
SELECT pos_num , pos_type , date
FROM loans L
JOIN payment P ON L.pos_num = P.pos_num AND L.pos_type = P.pos_type;
希望对您有所帮助。
我有两个 table,
第一 table --> 贷款, 列 --> pos_num , pos_type
第 2 table --> 付款, 列 --> pos_num , pos_type , 日期
我想从贷款中提取 pos_num , pos_type 值并放在下面的查询中
select count(1) from payment where pos_num = <value extracted from loans> and pos_type = <value extracted from loans> and date = <?>
我如何加入贷款 table 和付款 table 以获得我们应该在付款 table 中为 pos_num 获得相同数据的日期,pos_type 我们从贷款中得到 table
您可以使用 JOIN 语句获取值,例如:
SELECT pos_num , pos_type , date
FROM loans L
JOIN payment P ON L.pos_num = P.pos_num AND L.pos_type = P.pos_type;
希望对您有所帮助。