加入查询以显示2个表中的信息

时间:2014-12-30 17:47:41

标签: sql join

这是连接2个表的查询,但我在JOIN附近收到错误消息

select CHKNBR, pidamt, copied_from_batdat, BATDAT, SEQNBR from UMCDTL 
where copied_from_batdat between '10/11/2013' and '11/4/2013'
and batseq between '001' and '100' and SEQNBR between '01' and '100'
join
UMCFIL on BATDAT=SEQNBR and seqnbr=batadat

输出需要显示

Original Claim Number  
Original Paid Amount
Original Check Number

由于

2 个答案:

答案 0 :(得分:1)

如果您想使用'加入'特别是,它需要在你的' FROM'子句。

Select...
From
   table1 JOIN table2 ON Table1.key = Table2.key
Where...

如果您想使用' WHERE'加入表的子句,然后将关键字段关联在那里:

Select...
FROM
   table1, table2
WHERE
   table1.key = table2.key
   ...

如果想要更好地理解基本联接,请参阅以下教程:http://www.w3schools.com/sql/sql_join.asp

答案 1 :(得分:0)

尝试类似:

SELECT CHKNBR, pidamt, copied_from_batdat, BATDAT, SEQNBR 
FROM UMCDTL JOIN UMCFIL ON BATDAT=SEQNBR AND seqnbr=batadat
WHERE copied_from_batdat between '10/11/2013' AND '11/4/2013' 
AND batseq BETWEEN 1 AND 100 
AND SEQNBR BETWEEN 1 AND 100