MySQL - How to get data from two different tables into one table
I have the following tables
ps_ext_mod     ps_customer    ps_order_detail
---------      -----------    ---------------
id   开发者_如何学Go          .....          ..... 
cust      <==  email          .....
prod                  <==     product_reference
I need to add the data from email to cust and the data from product_reference into to prod.
Hopefully it should look something like this:
ps_ext_mod
-----------
id | cust   | product
---------------------
1  | a@a.com | prod1
2  | a@a.com | prod2
3  | b@b.com | prod1
4  | c@c.com | prod3
INSERT INTO ps_ext_mod (email, product) SELECT
   c.email, d.product
   FROM ps_customer c
   INNER JOIN ps_order_detail d ON (d.customer_id = c.id) 
You will need to tweak the join criterion a bit to match your database structure.
If the two tables are NOT related, then use a query like:  
INSERT INTO ps_ext_mod (email, product) SELECT
   c.email, d.product
   FROM ps_customer c
   CROSS JOIN ps_order_detail
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论