I have two tables. One is newBus, and Second is newPassengers. The table newBus contain the columns startcity and endCity. Now let say newBus.startCity contains:
newBus.id----newBus.startCity-----newBus.endCity
4 ACity to xCity
5 tCity to MCity
newPassenger table:
3 passengers wants to go to
newPassengers.s_city------newPassengers.e_city
tCity to GCity
OCity to FCity
tCity to MCity
I want to select the all passenger who want to go from tCity to MCity but with respect to newBus.id = 5.
This assumes that all passengers will get on a bus that has a start city the same as their start city, and that the ID of the passenger is newPassengers.id . You can add more fields to the select list to get the information you are after.