I have three tables:
locations
(haszipcode
,location name
);professionals
(hasname
);location_professional
.
I want to select only those rows from locations
table where professional_id
is 4. What's the best way to do this?
many-to-manyMySQL
I have three tables:
locations
(has zipcode
, location name
);professionals
(has name
);location_professional
.I want to select only those rows from locations
table where professional_id
is 4. What's the best way to do this?
Best Answer
Assuming that
locations
andprofessionals
also have their PK columns aslocation_id
andprofessional_id
, respectively, andlocation_professional
uses those columns to link the two entities:In your simple example, there is no need to also
JOIN professionals AS p ON ...
. In a typical case, that would also be needed.