Using GROUP BY/COUNTING:
SELECT t.bus_line_id,
t.bus_line_type,
t.bus_line_number
FROM BUS_LINE t
JOIN LINK_BUS_NEIGBOURHOOD lbn ON lbn.bus_line_id = t.bus_line_id
JOIN LINK_NEIGHBOURHOOD_STREET lns ON lns.neighbourhood_id_ns = lbn.neighbourhood_id_ns
JOIN STREET s ON s.street_id = lns.street_id
WHERE s.street_id IN (12, 14)
GROUP BY t.bus_line_id,
t.bus_line_type,
t.bus_line_number,
s.street_id
HAVING COUNT(DISTINCT s.street_id) = 2
Using JOINs:
SELECT t.bus_line_id,
t.bus_line_type,
t.bus_line_number
FROM BUS_LINE t
JOIN LINK_BUS_NEIGBOURHOOD lbn ON lbn.bus_line_id = t.bus_line_id
JOIN LINK_NEIGHBOURHOOD_STREET lns ON lns.neighbourhood_id_ns = lbn.neighbourhood_id_ns
JOIN STREET s ON s.street_id = lns.street_id
AND s.steet_id = 12
JOIN STREET s2 ON s2.street_id = lns.street_id
AND s2.steet_id = 14
OMG Ponies
2009-10-09 02:41:00