如何将此INNER JOIN查询从SQL Server转换为MySQL?

时间:2010-02-23 21:00:53

标签: sql mysql sql-server inner-join

我目前正在将客户端应用程序从带有SQL Server的Windows上的ColdFusion迁移到带有MySQL的Linux上的ColdFusion,我遇到了一些问题,重新创建了关于连接的视图。

任何人都可以帮我解决如何转换以下内容。

SELECT 
<columns> 
FROM assetType 
INNER JOIN assets
INNER JOIN AssetToContent ON assets.asset_id = AssetToContent.asset_id 
ON assetType.asset_typeID = assets.asset_typeID 
RIGHT OUTER JOIN ContentType 
INNER JOIN Content ON ContentType.ContentTypeID = Content.ContentTypeID 
ON AssetToContent.ContentID = Content.ContentID 
LEFT OUTER JOIN Page_Content ON Content.ContentID = Page_Content.ContentID 
RIGHT OUTER JOIN Page ON Page_Content.PID = Page.PID 

没有ON子句的INNER JOIN正在绊倒我,我找不到有关嵌套连接排序的任何好的SQL Server文档。

1 个答案:

答案 0 :(得分:3)

这应该有效。我不知道SQL Server使用什么voodoo语法,但你的ON条款到处都是:

SELECT 
<columns> 
FROM assetType 
INNER JOIN assets ON assetType.asset_typeID = assets.asset_typeID 
INNER JOIN AssetToContent ON assets.asset_id = AssetToContent.asset_id 
INNER JOIN Content ON AssetToContent.ContentID = Content.ContentID 
RIGHT OUTER JOIN ContentType ON ContentType.ContentTypeID = Content.ContentTypeID 
LEFT OUTER JOIN Page_Content ON Content.ContentID = Page_Content.ContentID 
RIGHT OUTER JOIN Page ON Page_Content.PID = Page.PID