这来自将 MSSQL 转换为 MySql。以下是我试图开始工作的代码:
CREATE TEMPORARY TABLE PageIndex (
IndexId int AUTO_INCREMENT NOT NULL PRIMARY KEY,
ItemId VARCHAR(64)
);
INSERT INTO PageIndex (ItemId)
SELECT Paths.PathId
FROM Paths,
((SELECT Paths.PathId
FROM AllUsers, Paths
WHERE Paths.ApplicationId = @ApplicationId
AND AllUsers.PathId = Paths.PathId
AND (@Path IS NULL
OR Paths.LoweredPath LIKE LOWER(@Path))) AS SharedDataPerPath
UNION -- This used to be a FULL OUTER JOIN but MySQL doesnt support that.
(SELECT DISTINCT Paths.PathId
FROM PerUser, Paths
WHERE Paths.ApplicationId = @ApplicationId
AND PerUser.PathId = Paths.PathId
AND (@Path IS NULL
OR Paths.LoweredPath LIKE LOWER(@Path))) AS UserDataPerPath
ON SharedDataPerPath.PathId = UserDataPerPath.PathId)
WHERE Paths.PathId = SharedDataPerPath.PathId OR Paths.PathId = UserDataPerPath.PathId
ORDER BY Paths.Path ASC;
假设任何变量已经存在。这在“As SharedDataPerPath”部分中断,所以我猜我给select语句加上别名,以便您可以像MySQL不支持表一样访问它?如果表模式有帮助,请回复评论,我会将其添加到问题中。
提前致谢!