Answer the question
In order to leave comments, you need to log in
Which join is better (WHERE or JOIN)?
Scheme:
Joining with JOIN:
Code:
SELECT Мастеры.ФИО AS Мастер, Услуги.Название AS Название,
Услуги.Стоимость AS Стоимость, Услуги.Половая_принадлежность AS [Половая принадлежность]
FROM Услуги
INNER JOIN (Мастеры
INNER JOIN Мастер_Услуга
ON Мастеры.Код_Мастера=Мастер_Услуга.Код_Мастера)
ON Услуги.Код_Услуги=Мастер_Услуга.Код_Услуги;
SELECT Мастеры.ФИО AS Мастер, Услуги.Название AS Название,
Услуги.Стоимость AS Стоимость, Услуги.Половая_принадлежность AS [Половая принадлежность]
FROM Мастеры, Услуги, Мастер_Услуга
WHERE Мастеры.Код_Мастера = Мастер_Услуга.Код_Мастера
AND Услуги.Код_Услуги = Мастер_Услуга.Код_Услуги;
Answer the question
In order to leave comments, you need to log in
So many different database tags, each database has its own profiling tools, run both queries through them. If both queries are equally fast, then the best option is the one that is more understandable and pleasant to you.
The first option is not very good, because it contains a subquery, and this is an additional execution time.
The option with commas has a right to exist, but, in my opinion, it is not very convenient to read.
I would write like this
SELECT Мастеры.ФИО AS Мастер, Услуги.Название AS Название, Услуги.Стоимость AS Стоимость, Услуги.Половая_принадлежность AS [Половая принадлежность]
FROM Мастер_Услуга
INNER JOIN Мастеры
ON Мастеры.Код_Мастера = Мастер_Услуга.Код_Мастера
INNER JOIN Услуги
ON Услуги.Код_Услуги = Мастер_Услуга.Код_Услуги
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question