我想填表E,我有这些表。
表A
+------+--------+--------+
| A_ID | A_NAME | A_TYPE |
+------+--------+--------+
| 1 | apple | 1 |
+------+--------+--------+
表B
+------+---------+--------+
| B_ID | B_NAME | FROM_A |
+------+---------+--------+
| 1 | A_NAME | A_ID |
+------+---------+--------+
表C
+-------+------------+
| C_ID | C_NAME |
+-------+------------+
| A_TYPE| fruit |
+-------+------------+
| A_TYPE| vegetables |
+-------+------------+
表D
+------+---------+
| D_ID | D_NAME |
+------+---------+
| 1 | fruit |
+------+---------+
表E
+------+--------+
| E_ID | E_NAME |
+------+--------+
| B_ID | D_ID |
+------+--------+
我如何填写and , where the TableE
with D_Name, and between and no key, only through and , where the is key.TableB B_ID
TableD D_ID
C_Name =
TableC
TableD
TableA
TableB
A_ID
因此,如果 apple 是水果,请在 and 中写入TableE
一条B_ID
SQLD_ID
语句。我怎样才能做到这一点?
我在 TableA 和 TableB 中有 2000 行我想将 C_Name 与 D_Name 进行比较,如果相同,则在 TableE 中写入来自 TableB 的 ID 和来自 TableD 的 ID。