Tina
Tina

Reputation: 47

Does a join between two tables always happen over a foreign key?

Does a join between two tables always happen over a foreign key?

Upvotes: 2

Views: 51

Answers (2)

aph5
aph5

Reputation: 791

No, you can use any column make a join. FK is preferred for greater performance, as it has an index on it.

Upvotes: 1

elixenide
elixenide

Reputation: 44841

In a word, no.

You can do a join on any condition, whether or not it is or uses a foreign key. In theory, it can be on no condition at all (a Cartesian join), although that's a bad idea.

Upvotes: 5

Related Questions