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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    LIKE not working as excepted?

    Hi,

    My LIKE in sql queries isn't working as I excepted, I'm not good with sql so any help would be great!

    I run this query

    SELECT * FROM people WHERE readers > '0' AND subscribers > '0' AND minValue < '5' AND about LIKE '%40%' AND country=1 OR country=2

    It must only return where people in the about field has the value 40 somewhere. The problem is it returns all of them as if the LIKE caluse isn't present?

    I'm not sure why when I just run

    SELECT * FROM people WHERE about LIKE '%40%'

    It does only return the ones it should

    Any ideas?

    Thanks!

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,307
    Thanks
    23
    Thanked 612 Times in 611 Posts
    If I get what your looking for [no parentheses makes it vague)
    SELECT * FROM people WHERE readers > '0' AND subscribers > '0' AND minValue < '5' AND about LIKE '%40%' AND (country=1 OR country=2)
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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