SELECT *
FROM paymentdetails,saletrack
WHERE saletrack.Date = paymentdetails.Date
但它返回零行
答案 0 :(得分:1)
听起来您可能需要UNION
而不是JOIN
:
SELECT CustomerID,CustomerName,Date
FROM paymentdetails
UNION ALL
SELECT CustomerID,CustomerName,Date
FROM saletrack
ORDER BY Date
由于您在两个表格中有不同的字段,因此您只需选择两个表格中的字段,或添加NULL
字段,例如,如果您想要包含Amountofpaying
} field:
SELECT CustomerID,CustomerName,Date
,Amountofpaying
FROM paymentdetails
UNION ALL
SELECT CustomerID,CustomerName,Date
,NULL AS Amountofpaying
FROM saletrack
注意:UNION ALL
会带回所有记录,而UNION
会排除重复的行。