I'm a little confused about the natural join in mysql.
Suppose that: There are two tables
table1
has columns: id, name, address, number (id is the PK of table1)
table2
has columns: id, name, number, money (id is the PK of table2)
I have already make "id"
of table1
a foreign key, referencing the "id"
of table2
and suppose "number"
in table1
is "people's number"
and "number"
in table2
is "telephone number"
those two columns have different meaning but same name
When I do the natural join of table1
and table2
:
Does mysql just simply check all the columns of table1
and table2
, whose name are same, which means that a tuple(row) will be selected ,if and only if, "id"
, "name"
and "number
" must be all same (for example, the "id"
and "name"
are same but "number"
is different, the row will not be selected)?
OR
Does mysql will only check the foreign keys created, which means that a row will be selected , if and only if, "id"
is same?
another question is:
after natural join of table1
and table2
, will there be only 1 column called "id"
or 2 columns called "table1.id"
and "table2.id"
??
Thanks indeed!