I want to fill up TableE, and I have these tables.
TableA
+------+--------+--------+
| A_ID | A_NAME | A_TYPE |
+------+--------+--------+
| 1 | apple | 1 |
+------+--------+--------+
TableB
+------+---------+--------+
| B_ID | B_NAME | FROM_A |
+------+---------+--------+
| 1 | A_NAME | A_ID |
+------+---------+--------+
TableC
+-------+------------+
| C_ID | C_NAME |
+-------+------------+
| A_TYPE| fruit |
+-------+------------+
| A_TYPE| vegetables |
+-------+------------+
TableD
+------+---------+
| D_ID | D_NAME |
+------+---------+
| 1 | fruit |
+------+---------+
TableE
+------+--------+
| E_ID | E_NAME |
+------+--------+
| B_ID | D_ID |
+------+--------+
How can I fill TableE
with TableB B_ID
and TableD D_ID
, where the C_Name =
with D_Name, and between TableC
and TableD
no key, only through TableA
and TableB
, where the A_ID
is the key.
So, if apple is a fruit, write in TableE
the B_ID
and D_ID
, with one SQL statement.
How can I do this?
I have 2000 row in TableA and TableB I want to compare the C_Name with D_Name, and if its the same, write in the TableE the ID from TableB and the ID from TableD.