SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    501
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Multiple Options

    let's say i have a database with three tables. one that stores beach balls, another one that stores colors, and another one that ties them together.

    tblBeachballs
    ------------------
    BeachballID
    Name
    Size

    tblColors
    ------------------
    ColorID
    Color

    tblBeachballColor
    ------------------
    BeachballColorID
    BeachballID
    ColorID

    now - let's say i want to find a beachball that has red, yellow, and green stripes. how would i structure query to do such a search?

    SELECT b.Name
    FROM tblColors AS c INNER JOIN (tblBeachballs AS b INNER JOIN tblBeachballColor AS bc ON b.BeachballID = bc.BeachballID) ON c.ColorID = bc.ColorID WHERE c.ColorID IN (3, 2, 6)

    assuming that the ColorID's for red, yellow, and green were 3, 2, 6

    this works, to an extent... but it will pull any ball that has those colors in it. i want to make sure the more specific i get with the colors, the narrower my results.

    if i choose one color, fine - i should expect a ton of results. but as i pick more, i'd like it to narrow down.

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)


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
  •