Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sql

Options
  • 30-01-2006 11:16pm
    #1
    Closed Accounts Posts: 175 ✭✭


    jst wondering if you could help out i have a string in sql containg a number of postcodes whats the best way for me to search

    at the moment i can only do one

    & "AND (post_code LIKE '" & psPostCode & "')"

    now that will work happily for one postcode(ie 03) but say i have ('03', '08', '13') all in my string how do i go about it?

    cheers


Comments

  • Closed Accounts Posts: 131 ✭✭cognos


    Use IN instead of LIKE

    I think that will do it for you.


  • Closed Accounts Posts: 175 ✭✭napalm@night


    yeah but that will only do extact matches, i also need do do wild cards like say '1%'

    any ideas

    cheers


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    AND ( Postcode LIKE 'firstPossibility'
          OR Postcode LIKE 'secondPossibility'
          OR Postcode LIKE 'thirdPossibility'
    ...
    )
    

    There is no SQL operator which combines LIKE and IN.

    You need to parse your input string into individual postcode 'tokens', and build a statment like the one I have above.


  • Closed Accounts Posts: 175 ✭✭napalm@night


    cheers


Advertisement