我想根据事务表的三列从主表中查询客户名称。
我在Access 2010中有两个表(从dbf文件导入):
MASTER表
+------------+-----------------+
| Field | Sample data |
+------------+-----------------+
| type | G or S or C |
| MASTERcode | 10 or 20 or 30 |
| SUBcode | A1 or b1 or c1 |
|Customername| xyz ind |
| Address | data |
| OTHERS | OTHER DATA |
+------------+-----------------+
客户名称将有三个与其相关的字段|主代码| sucode
TRANSACTION表
+------------+-----------------+
| Field | Sample data |
+------------+-----------------+
| type | G or S or C |
| MASTERcode | 10 or 20 or 30 |
| SUBcode | A1 or b1 or c1 |
| TRN DATE | DATE |
| TRN AMOUNT | AMOUNT |
| OTHERS | OTHER DATE |
+------------+-----------------+
交易表有三种归档类型| mastercode |子代码与其他数据。
我该如何解决这个问题?
答案 0 :(得分:1)
目前还不完全清楚你想要的结果是什么,但你可以为此做一个简单的JOIN
:
SELECT T.*, --list of the columns from the Transaction table
M.Customername
FROM TRANSACTION_TABLE AS T
INNER JOIN MASTER_TABLE AS M
ON T.type = M.type AND T.MASTERcode = M.MASTERcode
AND T.SUBcode = M.SUBcode