I have trouble grasping joins between more that two tables and it’s syntax.
I need to grab parent Staff Name, Vendor Name, Zone ordered by zone. Unsure if this is enough data.
TABLES
vendor
vendor_staff
type_zone
This is my weirdest attempt ever and I believe I’m very far away. I know that I’m missing possible enclosed parenthesis clauses.
QUERY
SELECT
vendor.name AS Vendor, vendor_staff.vendorstaff AS Staff,type_zone.type AS Region
FROM dbo.vendor inner join dbo.type_zone
ON fkType_zoneID = pkType_ZoneID
WHERE dbo.vendor.active = 1 and vendor_staff.fkVendorID = vendor.PkVendorID
ORDER BY type_zone.type, name
The three tables could be join using:
vendor.pkvendorID = vendor_staff.fkVendorID
type_zone.pkType_ZoneID = vendor.fkType_zoneID
The result should return per row Staff – > Vendor -> Zone
1 Answer