これは動物公園の例です。SQL INNER JOIN派生テーブルを使用したサブクエリ
employee、animal、animal_employeeの3つのテーブルがあります。これらのテーブルの間には、n:mテーブルがあります。 私は同じ動物を扱う従業員に問い合わせたいと思う。しかし私がやっているやり方では、私はID番号だけを出力することができます。私は、テーブルにある実際の名前を出力したい:従業員と動物。
これは私が今のところ持っているものです:FROM
句の
select distinct a.animal, a.employee, b.employee
from animal_employee a, animal_employee b
where a.animal = b.animal and a.employee > b.employee
テーブルスキーマを転記します。 – McNets