Of the two queries below, which is the most efficient for postgresql? And which has better style in terms of readability, etc.
The difference is the placement of the statement doctor.type != 'surgeon'
Inside the WHERE clause:
SELECT practice.name, doctor.name
FROM doctor
JOIN practice ON (doctor_code = code)
WHERE doctor.name LIKE '%son'
AND (doctor.type != 'surgeon');
or inside the JOIN clause:
SELECT practice.name, doctor.name
FROM doctor
JOIN practice ON (doctor_code = code AND doctor.type != 'surgeon')
WHERE doctor.name LIKE '%son';
practice.doctor_code = doctor.code
– ypercubeᵀᴹ Nov 3 '14 at 11:52