Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Where 'in'?

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where 'in'?

    Hi everybody.

    I have a stored procedure in MySql and I want to pass in a string (strCodes)of comma delimited codes, i.e. "'N', 'NC', 'NCA'" and then do a select along the lines of:

    SELECT code FROM table WHERE code IN (strCodes);

    However, this isn't returing the desired result. I've tried running the hard-coded sql (below) in query browser but that just gives "syntax error near '' "... which isn't helping either. Any ideas? Anybody?

    SELECT
    codes
    FROM table
    WHERE (codes IN ('N','NC','NCA'));

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    that code won't produce an error. are you doing it in php or something? directly in your mysql client it won't throw an error.

    what is the exact line you are running and what is the exact error?

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    That semi-colon at the end of the query will produce a syntax error if you run it in phpMyAdmin. That might be your problem.

    As for your original problem, what results are you getting, if not the desired ones?

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Loughborough (UK)
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks guys!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •