“为什么我在它存在时仍然收到“关系不存在”的消息?”

huangapple go评论114阅读模式
英文:

Why am i getting "relation does not exist" when it does?

问题

我在尝试使用以下查询填充我的表时遇到了错误:

INSERT INTO d_table
SELECT category.name, film_category.film_id
FROM category
INNER JOIN film_category ON film_category.category_id = category.category_id

它返回一个错误

"关系 film_category.film_id 不存在"

这是数据库中的表:

category
category_id
name

film_category
film_id
category_id

需要在表中使用这两个字段。

英文:

I'm getting an error while attempting to populate my table with the following query:

INSERT INTO d_table
SELECT category.name, film_category.film_id
FROM category
INNER JOIN film_category.film_id ON film_category.category_id = category.category_id

It returns an error

> "relation film_category.film_id does not exist"

These are the tables in the database:

**category**
category_id
name         


**film_category**
film_id
category_id

Need both fields in table.

答案1

得分: 2

你的INNER JOIN似乎不正确。您没有指定关系,而是列。我认为您想要

INSERT INTO d_table
SELECT
category.name, film_category.film_id
FROM category
INNER JOIN film_category
ON film_category.category_id = category.category_id

英文:

Your INNER JOIN doesn't appear to be correct. You aren't specifying a relation, but a column. I think you wanted

INSERT INTO d_table
    SELECT
        category.name, film_category.film_id
    FROM category
    INNER JOIN film_category
    ON film_category.category_id = category.category_id

答案2

得分: 0

因为你的FROM子句中没有关系film_category

英文:

Because you don't have relation film_category in your from clause

huangapple
  • 本文由 发表于 2023年5月18日 07:54:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276887.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定