sqlmysqljoinpopulate

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


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.


Solution

  • 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