+3  A: 

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
Thank you very much, but those queries give an empty result. I think they only give the buses that have two different streets in the same neighbourhood, but the two requests have to take different "path" each.
Julien
Ok i figured out how to do it, thanks to you !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_BUS_NEIGBOURHOOD lbn2 ON lbn2.bus_line_id = t.bus_line_idJOIN LINK_NEIGHBOURHOOD_STREET lns ON lns.neighbourhood_id_ns = lbn.neighbourhood_id_ns JOIN LINK_NEIGHBOURHOOD_STREET lns2 ON lns2.neighbourhood_id_ns = lbn2.neighbourhood_id_nsAND lns2.street_id=21AND lns.street_id=14
Julien
+2  A: 

Assuming you want three separate records in your sample result set and assuming that all the "neighborhood_id" columns are FKs back to the neighborhood table, try:

SELECT * 
  FROM bus_line 
 WHERE EXISTS (SELECT * 
                 FROM neighborhood N 
           INNER JOIN link_neighborhood_street S ON N.neighborhood_id = S.neighborhood_id_ns 
                WHERE S.street_id = 12) 
  AND EXISTS (SELECT * 
                FROM neighborhood N 
          INNER JOIN link_neighborhood_street S ON N.neighborhood_id = S.neighborhood_id_ns 
               WHERE S.street_id = 14);
Larry Lustig
This request looks quite close to what I am looking for, thanks ! But like this it gives me all the bus lines. I think it is logic because there is no link between the bus_line table and the neighbourhood. I do not know about the EXISTS function but i will try to have a look at it. Maybe like this : EXISTS (SELECT * FROM bus_line B INNER JOIN neighborhood... ?
Julien
@Larry: You need to correlate the EXISTS with the BUS_LINE table.
OMG Ponies