以下代码匹配来自 2 个表的结果并返回多个结果。所以这部分代码有效:`
SET @t1 :=
(SELECT
user_id
FROM
test.wp_usermeta wp_usermeta,
test.subs subs
WHERE
wp_usermeta.meta_value = subs.email
);
SET @t2 :=
(SELECT
cusid
FROM
test.wp_usermeta wp_usermeta,
test.subs subs
WHERE
wp_usermeta.meta_value = subs.email
);`
但是,当我尝试全部执行输入函数时,它只添加一行,而我实际上希望它为上面代码给我的所有结果添加一个新行。这是带有插入功能的代码:
SET @t1 :=
(SELECT
user_id
FROM
test.wp_usermeta wp_usermeta,
test.subs subs
WHERE
wp_usermeta.meta_value = subs.email
);
SET @t2 :=
(SELECT
cusid
FROM
test.wp_usermeta wp_usermeta,
test.subs subs
WHERE
wp_usermeta.meta_value = subs.email
);
INSERT test.wp_usermeta(umeta_id, user_id, meta_key, meta_value)
VALUES (NULL, @t1, "_stripe_customer_id", @t2)
我收到以下错误消息:
Query: SET @t1 error : Subquery returns more than 1 row
Query: SET @t2 error : Subquery returns more than 1 row
这是唯一的成功信息:
INSERT test.wp_usermeta(umeta_id, user_id, meta_key, meta_value)
VALUES (NULL, @t1, "_stripe_customer_id", @t2) : affected rows : 1
任何建议将不胜感激,在此先感谢您。