SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2002
    Location
    London UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Simple SQL problem, I think!

    I have two tables, see below:

    +------+------------+ +---------+------------+
    |Car_ID|Car ||||||||| |Colour_ID|Colour ||||||
    |------|------------| |---------|------------|
    || 01 ||Ford |||||||| ||| 01 ||||Blue ||||||||
    || 02 ||Jeep |||||||| ||| 02 ||||Green |||||||
    || 03 ||Nissan |||||| ||| 03 ||||yellow ||||||
    || 04 ||Jaguar |||||| ||| 04 ||||Red |||||||||
    || 05 ||TVR ||||||||| ||| 05 ||||Pink ||||||||
    +------+------------+ +---------+------------+

    There are many colours available to one car.

    What I want is a detail page for each car, with the available colours listed in a field (the car may be available in more than one colour)

    The thing is that if I add another car (say, Mazda) and it comes in a new colour (say, silver) I want to be able to just add this new colour onto the bottom of the colour table so that its available to select when I input the new car. How can I store the colours a car is available in, in the car table, is there some sort of array function?

    Any help would be great.

    Tom
    tom@dession.com
    Last edited by tombandy; Sep 12, 2002 at 03:21.

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just make a new relationships table. For instance, if Ford is available in blue, yellow, and red, and Jaguar is only in blue, you might have...
    Code:
    'Colors_Available
    +---+-----+
    |Car|Color|
    +---+-----+
    |01 | 01  |
    |01 | 03  |
    |01 | 04  |
    |04 | 01  |
    +---+-----+
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    SitePoint Member
    Join Date
    Sep 2002
    Location
    London UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Thanks

    Thanks randem, that works great, I didn't even think to try a new table with the relations in it.

    Thanks again.


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
  •