Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +--------+-------------+-------+----------+------------+
- | CityID | City | State | TimeZone | UserAccess |
- +--------+-------------+-------+----------+------------+
- | 1 | Albany | NY | 4 | 1 |
- | 2 | Allentown | PA | 6 | 1 |
- | 3 | Albuquerque | NM | 4 | 1 |
- | 4 | Amarillo | TX | 3 | 1 |
- | 5 | Atlanta | GA | 4 | 1 |
- +--------+-------------+-------+----------+------------+
- +--------+----------+
- | CityID | RegionID |
- +--------+----------+
- | 1 | 14 |
- | 1 | 15 |
- | 2 | 14 |
- | 3 | 11 |
- | 4 | 12 |
- | 4 | 13 |
- | 5 | 12 |
- | 5 | 13 |
- +--------+----------+
- +----------+-----------+--------+
- | RegionID | Region | TypeID |
- +----------+-----------+--------+
- | 10 | West | 1 |
- | 11 | West | 2 |
- | 12 | South | 1 |
- | 13 | South | 2 |
- | 14 | Northeast | 1 |
- | 15 | Northeast | 2 |
- +----------+-----------+--------+
- SELECT DISTINCT Cities.CityID
- FROM Cities
- INNER JOIN CitiesToRegions on Cities.CityID = CitiesToRegions.CityID
- FULL JOIN Regions on CitiesToRegions.RegionID = Regions.RegionID
- WHERE (CitiesToRegions.RegionID is null) AND (Cities.UserAccess=1) AND (Regions.TypeID != 1)
- +--------+
- | CityID |
- +--------+
- | 3 |
- +--------+
Add Comment
Please, Sign In to add comment