以下は私が実行しようとしているクエリです。
select
from_country_id,
to_country_id,
fromCountry.country_name as from_country_name,
to_country_id.country_name as to_country_name
from TourDetails t
left join country fromCountry on fromCountry.id = t. from_country_id
left join country toCountry on toCountry.id = t. to_country_id
国IDと国IDを保存するtourdetailsテーブルがあります。国IDと国名を持つ別の国テーブルがあります。
これで、tourdetailsテーブルをクエリするときに、国名も取得する必要があります。このために、郡のテーブルとの左結合を2回使用しています。
この国のテーブルに2回参加しなくても、fromとtoの国の両方の国名を取得する方法はありますか?