我已经读过this https://stackoverflow.com/questions/20426967/adding-two-select-statements-into-one-insert-into-statement-in-postgresql, this https://stackoverflow.com/questions/33791061/postgres-insert-into-with-two-select-statements and this https://stackoverflow.com/questions/3736732/update-or-insert-multiple-rows-and-columns-from-subquery-in-postgresql,但我无法让这个 SQL 工作:
INSERT INTO main_phrase (description) VALUES ('Mot commun féminin pluriel animaux');
/* ERROR: */
WITH
t1 AS (
SELECT id
FROM main_phrase
WHERE description='Mot commun féminin pluriel animaux'
),
t2 AS (
SELECT id
FROM main_groupecategories
WHERE description='Mot commun féminin pluriel animaux'
)
INSERT
INTO main_phrasegroupecategories (phrase_id, groupe_categories_id)
VALUES (t1.id, t2.id);
I get:
错误:缺少表 t1 的 FROM 子句条目
我缺少什么?
尝试这个:
INSERT INTO main_phrase (phrase_id, groupe_categories_id)
WITH
t1 AS (
SELECT id
FROM main_phrase
WHERE description='Mot commun féminin pluriel animaux'
),
t2 AS (
SELECT id
FROM main_groupecategories
WHERE description='Mot commun féminin pluriel animaux'
)
select t1.id, t2.id
from t1,t2;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)