#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Copenhagen, Denmark
    Posts
    3
    Rep Power
    0
    Hi, I'm having two tables a person and a profile table. The profile consist of categories, and each person can be in one or more categories. And now I want to be able to find persons based on their profile.

    If I searc on one category in the profile table it works fine, but not if I want to search on multiple categories.

    select Name from A, B where B.cat1 = 'y' and A.id = B.id

    That work fine, but this selects all persons in the database

    select Name from A, B where B.cat1 = 'y'OR B.cat2 = 'y' and A.id = B.id


    I really can't get my head around this, any help is appreciated.

    Erik
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    You need some parenthesis in there:

    select Name from A, B where (B.cat1 = 'y'OR B.cat2 = 'y') and A.id = B.id

Similar Threads

  1. MSACCESS:Using a left join to join a table to a subquery?
    By Handsy11 in forum Database Management
    Replies: 1
    Last Post: May 5th, 2004, 06:06 PM
  2. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 02:21 PM
  3. SELECT COUNT(), JOIN AND GROUP Problem...
    By DustinDavis in forum MySQL Help
    Replies: 9
    Last Post: February 5th, 2004, 03:06 PM
  4. WinNT4 problem
    By sandipguha in forum Windows Help
    Replies: 0
    Last Post: January 27th, 2004, 02:06 AM
  5. Session Variable problem :(
    By modesty in forum PHP Development
    Replies: 1
    Last Post: January 15th, 2004, 04:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo