Aakash Goyal Aakash Goyal - 4 months ago 10x
SQL Question

Natural Join Query returns zero results even if the column name is same and have single matching column

I am using MySQL workbench 6.0.

I have following tables:

Actor, film_Actors

both have only one common column with name actor_id and have the same data type.

Sample Data:

select * from actor; gives:

enter image description here

and select * from film_actor; gives:

enter image description here

But when I ran Natural join query:

select actor_id, first_name, film_id from actor natural join film_actor;

Zero rows are returned. why?


A natural join will join using all columns that exist in both tables.

In your case, that includes last_update, and that is probably not what you want.

It is usually a good idea not to use natural join for reasons like this.