在你的 SQL 查询中,你使用了不正确的语法。错误出现在 FROM 子句的开头:\n\nFROM(SELECT pbcb.warehouseCode, pw.chargeLocation, pbcb.chargeCategory, pbcb.chargeItemCode, pbcb.chargeItemName, pbcb.clientCode, pbcb.brandType, pbcb.netPrice, pbcb.plantCode, pbcb.whAttribute, pbcb.chargesType, pbcb.district, pbcb.feeDesc, pbcb.active, pbcb.userDef1, pw.locationCode as userDef2, NOW() as created, "$session.user" as createdBy, NOW() as lastUpdated, '$session.user' as lastUpdatedBy\n应该修改为:\n\nFROM (SELECT pbcb.warehouseCode, pw.chargeLocation, pbcb.chargeCategory, pbcb.chargeItemCode, pbcb.chargeItemName, pbcb.clientCode, pbcb.brandType, pbcb.netPrice, pbcb.plantCode, pbcb.whAttribute, pbcb.chargesType, pbcb.district, pbcb.feeDesc, pbcb.active, pbcb.userDef1, pw.locationCode as userDef2, NOW() as created, "$session.user" as createdBy, NOW() as lastUpdated, '$session.user' as lastUpdatedBy\n你需要将全角的括号“()”改为半角的括号“()”。\n\n修改后的查询如下:\n\nSELECT tb.* FROM (SELECT pbcb.warehouseCode, pw.chargeLocation, pbcb.chargeCategory, pbcb.chargeItemCode, pbcb.chargeItemName, pbcb.clientCode, pbcb.brandType, pbcb.netPrice, pbcb.plantCode, pbcb.whAttribute, pbcb.chargesType, pbcb.district, pbcb.feeDesc, pbcb.active, pbcb.userDef1, pw.locationCode as userDef2, NOW() as created, "$session.user" as createdBy, NOW() as lastUpdated, '$session.user' as lastUpdatedBy\nFROM peps_bms_charges_basic pbcb\nLEFT JOIN peps_whattribute pw ON pw.warehouseCode = pbcb.warehouseCode AND pw.userDef1 = pbcb.userDef1\nWHERE 1 = 1\n AND pbcb.warehouseCode IS NOT NULL AND pw.chargeLocation IS NOT NULL AND pw.locationCode IS NOT NULL AND pbcb.chargeItemCode IS NOT NULL\n ) tb\nGROUP BY tb.warehouseCode, tb.chargeLocation, tb.userDef2, tb.chargeItemCode

MySQL 报错 1064: SQL 语法错误 - 解决方法

原文地址: http://www.cveoy.top/t/topic/pMlW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录