数据库 1
Table A
+-----+--------+---------------+
| ID | Price | Date |
+-----+--------+---------------+
| 1 | 100 | 2013.07.07 |
+-----+--------+---------------+
Table B
+------+--------+-------------+-------+
| ID | Name | Description | Stock |
+------+--------+-------------+-------+
| A-ID | Name1 | Good | 100 |
+------+--------+-------------+-------+
从这些到这些
Table C
+------+--------+---------------+--------+
| ID | Name | Description | Date |
+------+--------+---------------+--------+
| A-ID | B-Name | B-Description | A-Date |
+------+--------+---------------+--------+
Table D
+-------+------+-------+----------+
| D_ID | ID | Meta | MetaValue|
+-------+------+-------+----------+
| 1 | A-ID | price | A-Price |
+-------+------+-------+----------+
| 2 | A-ID | stock | B-Stock |
+-------+------+-------+----------+
如何用一个 PhP 代码填充 A 和 B 的 C 和 D 表?xS 在表 A 和表 B 中,我有 15.000~ 行 C 需要为每个项目制作 1 行 D 需要为每个项目制作 30 行具有不同的值(在表 A 和表 B 中)
我以这种方式填写“表 C”
INSERT INTO DB1.C (Name, Description)
SELECT b.Products_Name, b.Description
FROM DB1.B AS b
和
UPDATE DB1.C c, DB1.A a
SET c.Date=a.Date
WHERE c.ID=a.ID'