I have these tables :
I don't know how I can write a statement, that takes emails from Table "Firm", that have Location_id = '1'
and Category_id = '130';
I know that I should use JOINs, but I'm not sure how to go from there.
I have these tables :
I don't know how I can write a statement, that takes emails from Table "Firm", that have Location_id = '1'
and Category_id = '130';
I know that I should use JOINs, but I'm not sure how to go from there.
You could do:
SELECT f.email
FROM Firm f
WHERE f.firma_id =
(
SELECT ff.firma_id
FROM FirmID ff
WHERE ff.location_id = 1
AND ff.category_id = 130
)
Using an inner select.
But using JOINS is in the long term the way to go, what have you tried and what's not working?
Should be as simple as doing the following:
SELECT email
FROM Firm, FirmID
WHERE Firm.firma_id = FirmID.firma_id
AND FirmID.location_id = 1
AND FirmID.category_id = 130;
It does a join behind the scenes, but can be a bit clearer to understand than using the JOIN keyword.