如何从有关系的数据库中进行选择?
我的数据库的架构如下图所示,我需要选择与 [letaky] 的一行(一个 id)相关的所有内容。这意味着相关的 [zamestnanci]、每个相关的 [obsah] 以及其中的每个 [knihy]。
这是我第一次在数据库中使用关系,我不知道如何进行这样的选择。
I have database with schema on picture below and I need to select everything related to one row (one id) of [letaky]. That means the related [zamestnanci], every related [obsah] and every [knihy] in it.
This is the first time i used relations in database and i have no idea how to make such a select.
使用 JOIN ... ON:
您可能还需要考虑每个连接是否需要 INNER JOIN、LEFT JOIN 或 RIGHT JOIN。 StackOverflow 上的许多其他问题描述了这些 JOIN 之间的差异,例如这个:
SQL Join Differences
Use JOIN ... ON:
You may also want to consider whether you need INNER JOIN, LEFT JOIN or RIGHT JOIN for each of these joins. The difference between these JOINs is described in many other questions on StackOverflow, for example this one:
SQL Join Differences