+ 2
What's The join criterion
When i join with WHERE, what's the selection criterion of the elements of the second table? ID, primary key?
2 Respostas
+ 5
That's your call, but most often you should specify a condition on a key.
Take a look what your options are:
https://i.stack.imgur.com/3bs7C.png
+ 2
No need for primary key in this case but it'll be a good for standard (Indexing).
Just a Foreign key between both tables are very logically and to add an INDEX for that column on second table are.
- look :
Select S.*, T.* from Students S Inner join Teacher T on S.ClassID = T.ClassID
- In that case we'll make on Foreign key as an INDEX of fast data retrieval only but not mandatory.