下面是SQL Server查詢我想轉換到MySQL:轉換的SQL Server SQL查詢到MySQL
SELECT SaleDetail.cTaxiNo, Category.cCarName, qryDriverExpenses.nAmount,
Sale.nInvoiceNo, Sale.cCustomerName, IIf([cPackageType] ='GENERAL',
[nProviderRate],[nProviderRate]/[nProviderKM]) AS nARate, SaleDetail.nKM,
SaleDetail.nAmount, Sale.dInvoiceDate, qryFuel.nAmount,
SaleDetail.nProviderKM, SaleDetail.nProviderRate
FROM qryFuel
RIGHT JOIN (((Sale INNER JOIN SaleDetail ON Sale.nSalePk = SaleDetail.nSalePk)
INNER JOIN (CarMaster
INNER JOIN Category
ON CarMaster.nCategoryPk = Category.nCategoryPK) ON SaleDetail.cTaxiNo =
CarMaster.cCarNo)
LEFT JOIN qryDriverExpenses
ON SaleDetail.nTourBookingpk = qryDriverExpenses.nTourBookingPK)
ON qryFuel.nTourBookingPK =
SaleDetail.nTourBookingpk
ORDER BY Sale.nInvoiceNo, Sale.dInvoiceDate;
我得到錯誤的SQL
語法錯誤。附近[cPackageType]
請幫助!
有在MYSQL中沒有IIF,而是用IF來代替;如果([cPackageType] ='GENERAL', [nProviderRate],[nProviderRate]/[nProviderKM])AS nARate, – knkarthick24