使用1个条件的多个列中的SQL值对

时间:2015-10-11 12:49:29

标签: mysql sql

我有一张包含公共汽车旅行的表

id   busid  pickup   destination
1       1    NWD      KML
2       2    KML      ORL
3       2    ORL      ULI
4       3    ULI      OIL
5       4    YUT      CDN
6       5    CDN      UYT

我试图找到的是当用户选择拾取NWD和目标OIL时。 输出将是

1: Take bus 1 going from NWD to KML
2: Take bus 2 going from KML to ORL
3: Take bus 2 going from ORL to ULI
4: Take bus 3 going from ULI to OIL

或者如果用户选择提取NWD和目的地ULI

1: Take bus 1 going from NWD to KML
2: Take bus 2 going from KML to ORL
3: Take bus 2 going from ORL to ULI

如果用户选择提取YUT和目的地UYT

1: Take bus 4 going from YUT to CDN
2: Take bus 5 going from CDN to UYT

所以问题是我无法将所有列表附加到用户在取件和目的地上选择的内容。我怎么能得到那些?

0 个答案:

没有答案