一个INSERT与多个SELECT [英] One INSERT with multiple SELECT

查看:714
本文介绍了一个INSERT与多个SELECT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了

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);

我得到:

错误:表t1的FROM子句缺少条目

ERROR: missing entry for the clause FROM for table t1

我想念什么?

推荐答案

假设

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆