如何将多列连接为多列?

时间:2019-02-14 03:04:33

标签: mysql

我有一个trip表,其中包含from_cityto_city列,其中包含city表的外键。

如何使用以city作为主键的id表进行联接,以便获得具有from_city_nameto_city_name的结果联接表?

1 个答案:

答案 0 :(得分:1)

进行两次内部联接,如下所示。有关SQL连接的更多信息,请参见MySQL Join Made Easy For Beginners

#include <iostream>

using namespace std;

int main()
{

enum days { Sun, Mon, Tue, Wed, Thu,Fri,Sat };
int day;
cout << " Enter a day ";
cin >> day;

switch (day)
{
case 0:
    cout << "Weekend" << endl;
    break;

case 1:
    cout << "Start of work week " << endl;
    break;

case 2:
    cout << "Midweek" << endl;
    break;

case 3:
    cout << "Midweek" << endl;
    break;

case 4:
    cout << "Midweek" << endl;
    break;

case 5:
    cout << "End of work  week" << endl;
    break;

case 6:
    cout << "Weekend" << endl;
    break;

default:
   cout << "Invalid day of the week" << endl;
    return 0;

}
}