大家晚上好,我有一个大问题,因为如果我做得不对。因为我担心这个查询不会给我正确的信息。我有2个数据库,'indvalid_hya'和'uuid_sap'。
在我的数据库'indvalid_hya'中,我有以下表格,其中包含以下字段: 该表有一个主键,即'XML_ID',与ID表'FILE'
相关+------------+-------+-----------+-------------+------+-------+------------+
| ISSUEDDATE | TOTAL | ISSUERRFC | RECEIVERRFC | UUID | FOLIO | XML_ID (PK)|
+------------+-------+-----------+-------------+------+-------+------------+
| | | | | | | |
+------------+-------+-----------+-------------+------+-------+------------+
这是我在BD'Indvalid_hya'中的另一张表'DOCUMENT':
+------------+--------------+-----------+
| ID (FK) | BYTES | ISSUERRFC |
+------------+--------------+-----------+
| | | |
+------------+--------------+-----------+
最后我有了另一个名为'uuid_sap'的数据库。我在那里有3个老板,他们使用'ID'与其他2个桌子相关 表'DATOS_SAP':
+----------------+---------+-----------+
| UUID_SAP (FK) | NUM_DOC | SOCIETY |
+----------------+---------+-----------+
| | | |
+----------------+---------+-----------+
这是我的代码将我的表'DOCUMENT'和'FILE'绑定到我的BD'Indvalid_hya'与我的其他BD'uuid_sap'我的表'DATOS_SAP'
我的代码MySQL:
SELECT IH.ISSUEDDATE, IH.TOTAL, IH.ISSUERRFC, IH.RECEIVERRFC, IH.UUID, IH.FOLIO, F.BYTES, US.UUID_SAP
FROM indvalid_hya.DOCUMENT IH
INNER JOIN FILE F
ON IH.XML_ID = F.ID
INNER JOIN uuid_sap.DATOS_SAP US
ON IH.UUID = US.UUID_SAP
答案 0 :(得分:0)
这是解决方案,如果我错了,请告诉我你知道
SELECT DB1_T1.ISSUEDDATE, DB1_T1.TOTAL, DB1_T1.ISSUERRFC, DB1_T1.RECEIVERRFC, DB1_T1.UUID, DB1_T1.FOLIO, DB2_T1.UUID_SAP
FROM indvalid_hya.DOCUMENT DB1_T1
INNER JOIN indvalid_hya.FILE DB1_T2
ON DB1_T1.XML_ID = DB1_T2.ID
INNER JOIN uuid_sap.DATOS_SAP DB2_T1
ON DB1_T1.UUID = DB2_T1.UUID_SAP