+ 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?

4th May 2017, 10:42 AM
Henrique
Henrique - avatar
2 Answers
+ 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
4th May 2017, 1:54 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 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.
23rd May 2017, 5:57 PM
Mohamed Abulnasr
Mohamed Abulnasr - avatar