0

下面的语句将从 OpenQuery(MYSQL) 返回值。

Select * From OpenQuery(MYSQL, 'Select * From ResearchRpt') a
Where Not Exists (Select * From dbo.ResearchRpt where Id_report = a.Id_report)

我想在结果值应该出现的地方反转它 dbo.ResearchRpt

谢谢。

4

2 回答 2

2

您的查询使用反连接。反连接可以用LEFT JOIN+WHERE IS NULL和. 来实现NOT EXISTS。因此,将您的脚本转换为 LEFT JOIN 版本,交换边,您就完成了:

SELECT ms.*
FROM dbo.ResearchRpt ms
  LEFT JOIN OPENQUERY(MYSQL, 'SELECT * FROM ResearchRpt') my
    ON my.Id_report = ms.Id_report
WHERE my.Id_report IS NULL
于 2012-05-02T21:50:40.297 回答
1
-- Only exists

SELECT ms.*, my.Id_report
FROM dbo.ResearchRpt ms
LEFT JOIN OPENQUERY(MYSQL, 'SELECT * FROM ResearchRpt') my
ON my.Id_report = ms.Id_report
WHERE my.Id_report IS NOT NULL
于 2012-06-11T22:43:33.530 回答