小编典典

加入运算符和可交换性

sql

我正在做一些关系代数练习。在老师的幻灯片上,我看到了一件
让我觉得可能有错误的事情。我认为,第三个JOIN
应该是

JOIN 'Farmacia' as F
ON 'D'.'idCF' = 'F'.'idF矛

instead of

JOIN 'Farmacia' as F
ON 'F'.'idF矛 = 'D'.'idCF'

使用最后一个命令,您将自己加入Farmacia,不是吗?

The slide question says:

Which pharmacy does sell drug X of phramaceutic company Y?

enter image description here


阅读 210

收藏
2021-04-15

共1个答案

小编典典

语句的ON部分中的列顺序不影响
JOIN本身的完成方式。

This:

SELECT t1.columnA, t2.columnB
FROM Table1 t1
   JOIN Table2 t2 ON t1.ID = t2.ID

will yield the same results as this:

SELECT t1.columnA, t2.columnB
FROM Table1 t1
   JOIN Table2 t2 ON t2.ID = t1.ID

The self-join you described would have been something like this:

SELECT t1.columnA, t2.columnB
FROM Table1 t1
   JOIN Table1 t2 ON t1.managerID = t2.employeeID
2021-04-15