I've already read this, this and this, but I cant make this SQL work:
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:
ERROR: missing entry for the clause FROM for table t1
What am I missing?
Try this:
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;