我有两个桌子,
第一表->贷款, 列-> pos_num,pos_type
第二张表->付款, 列-> 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 = <?>
我们如何将贷款表与付款表连接起来,以获取在付款表中应该有与我们从贷款表获得的pos_num,pos_type相同的数据的日期
答案 0 :(得分:1)
您可以使用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;
希望能对您有所帮助。