私の問題では、私は旅行ルートテーブルと都市テーブルを持っています。ルートテーブルはあなたの起源都市とあなたの目的地の都市を都市ID、名前は別の表にあります。SQLクエリが間違っていると、1つのテーブルから2つの名前を検索する必要があります
私はX市から始まるすべてのルートを検索したい、このために、私はこのクエリ
SELECT ciudad.nombre as Origen,
ciudad.nombre as Destino,
km as Distancia,
rutas.km*rutas.precio_km as Precio,
fecha as Fecha
FROM rutas, ciudad where "Santiago"=ciudad.nombre and ciudad.id_ciudad=rutas.ciudad_or;
を作った。これは私が得る結果であり、注意原産地= DESTINO
これはRoutesテーブルです.ciudad_orとciudad_deはfromとtoの都市です。
これは私の都市テーブル
ですが、それもある(私はそれが正しい宛先を表示させる方法がわからない、私の元と私の目的地に同じ都市を印刷します同上)
私は都市名でルートを検索してい
いくつかのサンプルデータをお送りください。 – Blank
いくつかの画像を追加しました – user3577419
画像ではありません。テストテーブルを作成するためにコピーして貼り付けることはできません。表を作成するDDLと、表を作成するDML –