locked
sql query syntax RRS feed

  • Question

  • User-1004490012 posted

    I am having a little problem with my query. Please help.

    <code>

    SELECT        ps.Pants#, pmd.PantsModelName, pmk.PantsMakeName, pps.PantsPicName,
                                 (SELECT        COUNT(rdp.Pants#) AS Expr1
                                   FROM            rdp AS rdp_1) AS Expr1
    FROM            rdpPantsPic AS rdpp INNER JOIN
                             Pants AS ps INNER JOIN
                             PantsType AS ptp ON ps.Pants# = ptp.Pants# INNER JOIN
                             PantsMake AS pmk ON ps.PantsMake# = pmk.PantsMake# INNER JOIN
                             PantsModel AS pmd ON ps.PantsModel# = pmd.PantsModel# INNER JOIN
                             PantsCat AS pcs ON ptp.PantsType# = pcs.PantsType# INNER JOIN
                             PantsGender AS pgs ON pcs.PantsCat# = pgs.PantsCat# INNER JOIN
                              rddPants AS rdp ON ps.Pants# = rtp.Pants# ON rdpp.ReturnPants# = rdp.ReturnPants# INNER JOIN
                             PantsStore AS pss ON ps.Pants# = pss.Pants# INNER JOIN
                             Store AS ss ON pss.Store# = ss.Store# CROSS JOIN
                             PantsPic AS pps
    WHERE        (pgs.Gender = 2) AND (ss.Continent = 'North America') AND (rdpp.Count =
                                 (SELECT        MAX(Count) AS Expr1
                                   FROM            rdpp AS rdpPantsPic_1))

    </code>

    Tuesday, January 28, 2014 5:56 PM

Answers

  • User-933407369 posted

     

    Error in join expression.
    
    Unable to parse query text.
    

    There is an error in the syntax of your query. The Query Designer has attempted to locate the source of the error. Review your query syntax and correct the error before running your query.

    For more information, see Specifying Search Criteria (Visual Database Tools).

    you can try to use the code below:

    rdpp.Count in (SELECT        MAX(Count) AS Expr1
                                    FROM            rdpp AS rdpPantsPic_1))

    Hope it helps you.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 5, 2014 12:22 AM

All replies

  • User-933407369 posted

    hello,

    your issue "sql query syntax" is related to the "on" keyword, i would suggest you try to change " rddPants AS rdp ON ps.Pants# = rtp.Pants# on rdpp.ReturnPants# = rdp.ReturnPants# INNER" to " rddPants AS rdp ON ps.Pants# = rtp.Pants# and rdpp.ReturnPants# = rdp.ReturnPants# INNER" .  the complete sql statement as shown below :

    SELECT        ps.Pants#, pmd.PantsModelName, pmk.PantsMakeName, pps.PantsPicName,
                                  (SELECT        COUNT(rdp.Pants#) AS Expr1
                                    FROM            rdp AS rdp_1) AS Expr1
     FROM            rdpPantsPic AS rdpp INNER JOIN
                              Pants AS ps INNER JOIN
                              PantsType AS ptp ON ps.Pants# = ptp.Pants# INNER JOIN
                              PantsMake AS pmk ON ps.PantsMake# = pmk.PantsMake# INNER JOIN
                              PantsModel AS pmd ON ps.PantsModel# = pmd.PantsModel# INNER JOIN
                              PantsCat AS pcs ON ptp.PantsType# = pcs.PantsType# INNER JOIN
                              PantsGender AS pgs ON pcs.PantsCat# = pgs.PantsCat# INNER JOIN
                               rddPants AS rdp ON ps.Pants# = rtp.Pants# and rdpp.ReturnPants# = rdp.ReturnPants# INNER JOIN
                              PantsStore AS pss ON ps.Pants# = pss.Pants# INNER JOIN
                              Store AS ss ON pss.Store# = ss.Store# CROSS JOIN
                              PantsPic AS pps
     WHERE        (pgs.Gender = 2) AND (ss.Continent = 'North America') AND (rdpp.Count =
                                  (SELECT        MAX(Count) AS Expr1
                                    FROM            rdpp AS rdpPantsPic_1))

    Hope it helps.

    Wednesday, January 29, 2014 6:06 AM
  • User-1004490012 posted

    Error

    Error in join expression.

    Unable to parse query text.

    Sorry guys. I made a little mistake in the original code but I made your suggestion and it gave me the error above. The changed code is below.

    <code>

    SELECT        ps.Pants#, pmd.PantsModelName, pmk.PantsMakeName, pps.PantsPicName,
                                  (SELECT        COUNT(rdp.Pants#) AS Expr1
                                    FROM            rdp AS rdp_1) AS Expr1
     FROM            rdpPantsPic AS rdpp INNER JOIN
                              Pants AS ps INNER JOIN
                              PantsType AS ptp ON ps.Pants# = ptp.Pants# INNER JOIN
                              PantsMake AS pmk ON ps.PantsMake# = pmk.PantsMake# INNER JOIN
                              PantsModel AS pmd ON ps.PantsModel# = pmd.PantsModel# INNER JOIN
                              PantsCat AS pcs ON ptp.PantsType# = pcs.PantsType# INNER JOIN
                              PantsGender AS pgs ON pcs.PantsCat# = pgs.PantsCat# INNER JOIN
                               rdpPants AS rdp ON ps.Pants# = rdp.Pants# and rdpp.ReturnPants# = rdp.ReturnPants# INNER JOIN
                              PantsStore AS pss ON ps.Pants# = pss.Pants# INNER JOIN
                              Store AS ss ON pss.Store# = ss.Store# CROSS JOIN
                              PantsPic AS pps
     WHERE        (pgs.Gender = 2) AND (ss.Continent = 'North America') AND (rdpp.Count =
                                  (SELECT        MAX(Count) AS Expr1
                                    FROM            rdpp AS rdpPantsPic_1))

    </code>

    Friday, January 31, 2014 2:49 PM
  • User-933407369 posted

     

    Error in join expression.
    
    Unable to parse query text.
    

    There is an error in the syntax of your query. The Query Designer has attempted to locate the source of the error. Review your query syntax and correct the error before running your query.

    For more information, see Specifying Search Criteria (Visual Database Tools).

    you can try to use the code below:

    rdpp.Count in (SELECT        MAX(Count) AS Expr1
                                    FROM            rdpp AS rdpPantsPic_1))

    Hope it helps you.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 5, 2014 12:22 AM