我目前正在尝试将以下MS SQL查询转换为Informix,但我不确定如何。
SELECT NumPlan.DNOrPattern, Device.Name, DeviceNumPlanMap.Display, TypeModel.Name AS Model, DeviceNumPlanMap.NumPlanIndex,
Device.AddOnModules
FROM DeviceNumPlanMap INNER JOIN
Device ON DeviceNumPlanMap.fkDevice = Device.pkid INNER JOIN
NumPlan ON DeviceNumPlanMap.fkNumPlan = NumPlan.pkid INNER JOIN
TypeModel ON Device.tkModel = TypeModel.Enum
WHERE (TypeModel.Enum <> '10') AND (TypeModel.Enum <> '12') AND (TypeModel.Enum <> '120') AND (TypeModel.Enum <> '90') AND
(TypeModel.Enum <> '73') and (TypeModel.Enum <> '72') and (TypeModel.Enum <> '80') AND (DeviceNumPlanMap.NumPlanIndex = '1') ORDER BY NumPlan.DNOrPattern, DeviceNumPlanMap.NumPlanIndex
有关如何将此转换为Informix查询的任何帮助都将非常感激。
答案 0 :(得分:1)
在任一数据库中,我都会将此查询编写为:
SELECT np.DNOrPattern, d.Name, npm.Display, tm.Name AS Model, npm.NumPlanIndex,
d.AddOnModules
FROM DeviceNumPlanMap npm INNER JOIN
Device d
ON npm.fkDevice = d.pkid INNER JOIN
NumPlan p
ON npm.fkNumPlan = p.pkid INNER JOIN
TypeModel tm
ON d.tkModel = tm.Enum
WHERE tm.Enum NOT IN ('10', '12', '120', '90', '73', '72', '80') AND
npm.NumPlanIndex = '1'
ORDER BY np.DNOrPattern, npm.NumPlanIndex;
如果Enum
或NumPlanIndex
的数据类型不是字符串,则删除单引号。
这应该适用于任一数据库。但是,我认为你原来也应该这样。