尝试这个:
INSERT INTO Combined_List (Email, Product)
SELECT DISTINCT meta_value, item_name FROM user_list, order_items
WHERE meta_key LIKE '%user_email%'
或者:
INSERT INTO Combined_List (Email, Product)
SELECT DISTINCT meta_value, item_name FROM user_list
WHERE meta_key LIKE '%user_email%'
UNION
SELECT DISTINCT meta_value, item_name FROM order_items
WHERE meta_key LIKE '%user_email%'
编辑:
不知道你的结构,这是我能做的最好的
INSERT INTO Combined_List (Email, Product)
SELECT a.meta_value, b.item_name
FROM user_list a
JOIN order_items b ON a.meta_key = b.meta_key
where a.meta_key LIKE '%user_email%'
使用 PK - FK 关系而不是a.meta_key = b.meta_key