情報を取得するためにクエリを作成するのに助けが必要ですが、それを書くのに問題があります。
[table_People]
int id
var name
[table_Tools]
int id
var name
[table_Activity1]
int person_id
int tool_id
date delivery_date
[table_Activity2]
int person_id
int tool_id
date installation_date
クエリは、すべての人のリストと、アクティビティ 1 または 2 (2 つの間で発生した最新のアクティビティ) で使用された最新のツールの名前を返す必要があります。
SELECT
people.id AS personId,
people.name AS personName,
(
SELECT
tools.name AS toolName
FROM
activity1
JOIN
tools ON tools.id=activity1.tool_id
WHERE
activity1.id=people.id
UNION ALL
SELECT
tools.name AS toolName
FROM
activity2
JOIN
tools ON tools.id=activity2.tool_id
WHERE
activity2.id=people.id
ORDER BY
installationDate,deliveryDate
) AS toolName
FROM
people
ORDER BY
people.name
ASC
私が抱えている問題は、列名が異なるためエラーが発生するため、日付 (配送またはインストール) で並べ替えることができないことです。