StarsIn(actor, movie, date) Stars(name, address)
SELECT * FROM StarsIn, Stars WHERE name=actor
SELECT * FROM StarsIn JOIN Stars ON name=actor The JOIN ON syntax is arguably more readable since it's more explicit given that we have to name the two tables that we will be performing the joins on. This means that after the ON keyword, only columns belonging to the tables can be referenced
1. SELECT A, D, E, G FROM R, S WHERE A>100; 2. SELECT A, D, E, G FROM R INNER JOIN S ON S.E = R.E AND S.D = R.D WHERE A> 100; Both statements do the same thing, but query 2 is more explicit than query 1.
patients(id, first_name, last_name, address, dob, primary_insurance, primary_care); procedures(name, department, OR_room, timestamp_start, timestamp_end, patient_id, main_surgeon_name, department);
1) SELECT first_name, last_name FROM patients, procedures WHERE patients.id = procedures.patient_id and procedures.main_surgeon_name = 'Pollett' and procedure.timestamp_start > 01-01-2004:0000;
2) SELECT first_name, last_name FROM (patients JOIN procedures ON id = patient_id) Where main_surgeon_name = 'Pollett' and timestamp_start > 01-01-2004:0000; Querry 2 is more readable (you clearly see at the second line what had to be common between the two tables) and will avoid creating a huge temporary table with a lot of unnecessary data than creating a cross product of the two tables(providing that the engine does not optimize the query).
SELECT * FROM Actors, Novelist WHERE Actors.name = Novelist.name;
SELECT * FROM (Actors JOIN Novelist ON Actors.name = Novelist.name);
The 2nd query is better because it explicitly shows the operations we are performing on the relations. The 1st query implies that we compute a joins but the 2nd query explicitly shows that we make making a join operation on the given conditions(Edited: 2019-11-13)