skip to Main Content

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.

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. Because you don’t have relation film_category in your from clause

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search