如何解决这个子查询错误?

时间:2011-05-03 04:57:05

标签: mysql sql

你能告诉我这有什么不对吗? 它抛出错误

  

子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。

使用({?SUB_ALLOC_PARM}))意味着什么呢?我猜它的参数值是对的吗?

select  distinct LFS_LFS as DN
        , LFS_VONNR
        , LZL_REFNR
        , AGR_TEXT
        , LFS_KNR as Store
        , LFS_DATOK
        , FIL_INDEX as Store_name
        , LAN_TEXT as COUNTRY
        , LZL_MENGE as Qty
        , ANS_NAME1 AS 'Customer Name'
        , ANS_NAME2 AS 'Customer Address line 1'
        , ANS_STRASSE AS 'Customer Address line 2'
        , ANS_STRASSE_2 AS 'Customer Address line 3'
        , ANS_ORT AS 'City'
        , ANS_TITEL AS 'State'
        , LAN_TEXT AS 'Country'
        , ANS_PLZ AS 'PostCode'
        , ( select  FIL_NUMMER 
            from    FUTURA..V_FILIALEN as HO
            where   HO.FIL_LAND = STORE.FIL_LAND
                    and HO.FIL_MANDANT = 1
                    and HO.FIL_ART = 0
          ) as HO_BRANCH
from    FUTURA..V_LIEFHEAD,
        FUTURA..V_ARTIKEL,
        FUTURA..V_ART_KOPF,
        FUTURA..V_LIEFZEIL,
        FUTURA..V_LAGER as BR5,
        FUTURA..V_FILIALEN as STORE,
        FUTURA..V_ANSCHRIF,
        FUTURA..V_LAND
where   AGR_MANDANT = ART_MANDANT
        and AGR_WARENGR = ART_WARENGR
        and AGR_ABTEILUNG = ART_ABTEILUNG
        and AGR_TYPE = ART_TYPE
        and AGR_GRPNUMMER = ART_GRPNUMMER
        and LZL_REFNR = ART_REFNUMMER
        and ART_MANDANT = LFS_MANDANT
        and LFS_LFS = LZL_LFS and LFS_MANDANT = LZL_MANDANT
        and LFS_MANDANT = 1
        and LZL_REFNR <> 0
        and LZL_REFNR = BR5.LAG_REFNUMMER
        and LZL_MANDANT = BR5.LAG_MANDANT
        and BR5.LAG_MANDANT = 1
        and BR5.LAG_FILIALE = LFS_VONNR
        and FIL_MANDANT = LZL_MANDANT
        and FIL_NUMMER = LFS_KNR
        and LAN_MANDANT = FIL_MANDANT
        and LAN_NUMMER = FIL_LAND
        AND ANS_TYP = 2 -- branches
        AND ANS_COUNT = 1 -- sequence 1
        AND ANS_MANDANT = FIL_MANDANT
        AND ANS_NUMMER = FIL_NUMMER
        and LFS_LFS IN (
          select  distinct PVG_LIEFERSCHEIN 
          from    FUTURA..V_PVERFIL 
          where   PVG_NUMMER IN ({?SUB_ALLOC_PARM})
       )
order by 
        LFS_KNR

1 个答案:

答案 0 :(得分:2)

最有可能的是,

            select  FIL_NUMMER 
            from    FUTURA..V_FILIALEN as HO
            where   HO.FIL_LAND = STORE.FIL_LAND
                    and HO.FIL_MANDANT = 1
                    and HO.FIL_ART = 0

子句返回多个值。