将WHERE和AND分组为一组

时间:2019-02-07 00:56:36

标签: mysql sql sql-server database

我正在尝试运行此sql语句,但是它不起作用。.

select语句还可以,但是它的最下面却给我带来麻烦。

SELECT VRVDIL.INVOICE_DATE,
    VRVDIL.INVOICE_NO,
    VRVDIL.DEAL_NO,
    VRVDIL.COST,
    VVD.DEAL_DATE,
    VVD.SALESMAN_NAME,
    VVD.SIGNED_DATE,
    VVD.STOCK_NO,
    VVD.VEHICLE_ID,
    VVD.VEHICLE_SALES_GROUP_DESCRIPTION,
    VVD.INVOICE_TO_NAME,
    VRVS.DATE_SOLD,
    VRVS.DAYS_IN_STOCK_BEFORE_SOLD,
    VRVS.LOCATION_NAME,
    VRVS.STOCKED_DATE,
    VRVS.VEHICLE_CLASS_DESCRIPTION,
    VRVRD.BUYER_NAME,
    VRVRD.PURCHASING_PRICE,
    VRVRD.SELLING_PRICE,
    VRV.VIN,
    VRV.VEHICLE_TYPE,
    VRV.REGO_NO,
    VRV.REGISTRATION_EXPIRY_DATE,
    VRV.MODEL_ID,
    VRV.MAKE_ID,
    VRVDOL.QTY
FROM VW_RG_VEHICLE_DEAL_INVOICE_LINE VRVDIL,
VW_VEHICLE_DEAL VVD,
VW_RG_VEHICLE_DEAL_ORDER_LINE VRVDOL,
VW_RG_VEHICLE VRV,
VW_RG_VEHICLE_STOCKCARD VRVS,
VW_RG_VEHICLE_REGISTER_DETAIL VRVRD
WHERE (VRVDIL.VEHICLE_DEAL_KEY = VVD.VEHICLE_DEAL_KEY
AND VRVDOL.VEHICLE_DEAL_KEY = VVD.VEHICLE_DEAL_KEY
AND VVD.VEHICLE_KEY = VRV.VEHICLE_KEY
AND VRVS.VEHICLE_STOCKCARD_KEY = VVD.VEHICLE_STOCKCARD_KEY
AND VRVS.VEHICLE_KEY = VRV.VEHICLE_KEY
AND VRVS.VEHICLE_STOCKCARD_KEY = VRVRD.VEHICLE_STOCKCARD_KEY

什么是错误?

1 个答案:

答案 0 :(得分:1)

您想念右括号吗?

WHERE (VRVDIL.VEHICLE_DEAL_KEY = VVD.VEHICLE_DEAL_KEY
AND VRVDOL.VEHICLE_DEAL_KEY = VVD.VEHICLE_DEAL_KEY
AND VVD.VEHICLE_KEY = VRV.VEHICLE_KEY
AND VRVS.VEHICLE_STOCKCARD_KEY = VVD.VEHICLE_STOCKCARD_KEY
AND VRVS.VEHICLE_KEY = VRV.VEHICLE_KEY
AND VRVS.VEHICLE_STOCKCARD_KEY = VRVRD.VEHICLE_STOCKCARD_KEY)

在最后一个AND条件的末尾,您应该放一个右括号。