SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot xPox's Avatar
    Join Date
    Sep 2005
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    any of the 3 Skills can equal 'Juggling' (was "MYSQL query")

    I have a table (users) with the following columns:

    Name
    Skill1
    Skill2
    Skill3

    For this example, let's say I want to run a query for all users where Name equals "John" and any of the 3 Skills can equal "Juggling"

    -or-

    $query = SELECT * FROM users WHERE Name = 'John' AND (Skill1 = 'Juggling' OR Skill2 = 'Juggling' OR Skill3 = 'Juggling') ORDER BY...

    The parenthesis seem to be ignored in this query. Is there another way to do this?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    WHERE Name = 'John' AND 'Juggling' IN (Skill1,Skill2,Skill3)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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