之前SQL语句如下写,想按照下列方式写,增加取得TMPQZCUSTOMERTBL表中的两个字段PH,SEQ,请问如何更改
SELECT *
FROM Customer
WHERE EXISTS (SELECT DISTINCT (1)
FROM TMPQZCUSTOMERTBL
WHERE CustomerDt.电话1 = TMPQZCUSTOMERTBL.CUSTOMER_TEL
OR CustomerDt.电话2 = TMPQZCUSTOMERTBL.CUSTOMER_TEL
OR CustomerDt.电话3 = TMPQZCUSTOMERTBL.CUSTOMER_TEL)
------解决方案--------------------
- SQL code
SELECT Customer.*,TMPQZCUSTOMERTBL.PH,TMPQZCUSTOMERTBL.SEQFROM Customer, FROM TMPQZCUSTOMERTBL WHERE CustomerDt.电话1 = TMPQZCUSTOMERTBL.CUSTOMER_TEL OR CustomerDt.电话2 = TMPQZCUSTOMERTBL.CUSTOMER_TEL OR CustomerDt.电话3 = TMPQZCUSTOMERTBL.CUSTOMER_TEL
------解决方案--------------------
- SQL code
SELECT a.*,b.PH,b.SEQFROM Customer a inner join(SELECT DISTINCT CUSTOMER_TEL,PH,SEQ FROM TMPQZCUSTOMERTBL)bon a.电话1 = b.CUSTOMER_TEL OR a.电话2 = b.CUSTOMER_TEL OR a.电话3 = b.CUSTOMER_TEL
------解决方案--------------------
SELECT a.*,b.PH,b.SEQ
FROM Customer a inner join(
SELECT DISTINCT CUSTOMER_TEL,PH,SEQ FROM TMPQZCUSTOMERTBL)b
on a.电话1 = b.CUSTOMER_TEL OR a.电话2 = b.CUSTOMER_TEL OR a.电话3 = b.CUSTOMER_TEL
------解决方案--------------------
- SQL code
SELECT a.*,b.PH,b.SEQFROM Customer a inner join(SELECT CUSTOMER_TEL,PH,SEQ FROM TMPQZCUSTOMERTBL GROUP BY CUSTOMER_TEL,PH,SEQ )bon a.电话1 = b.CUSTOMER_TEL OR a.电话2 = b.CUSTOMER_TEL OR a.电话3 = b.CUSTOMER_TEL