Hi all. 
This may (or may not) be a newbie question. But I've called it a newbie
question since I am a newbie to MySQL (and SQL for that matter). Here is
what I want to do:

I want to join three tables into one, where one specific colomn may have
more than one entry for each row.

The spesifics are as follows:
I have three tables containing information about cars that are for sale.

-The first table is called "cars" and contain the following colomns: car_id
(a unique id for each car), modell (the year is was made), car_info (name of
the car), price (the price asked for). Ex:
1  1999  Ford Taurus  2K
2  2000  Chevy Pickup  1.5K
3  1971  Ford Cortina  4K

-The second table (Pics) contain two colomns: car_id (the same unique id as
in the first table) and file_name (the name of the picture-file). Ex:
1  car1_small.jpg
1  car1_big.jpg
2  car2_small.gif

-The third table (Viewing) tells me when each car may be seen by potensial
customers, useing these colomns: car_id (the unique id for each car), car_in
(the time a seller brings the car into the shop) and car_out (the time the
seller leaves or takes the car out). Ex:
1  May 25, 1pm  May 25, 3pm
1  May 27, 2pm  May 27, 3pm
1  May 28, 10am  May 28, 4pm

What I want to do is search for eg. Fords in all three tables, and join the
result into one table, with just one row for each car, even if there are
more than one (or even none) view-time. Thus:

-----------------------------------------------------------
|1 | Ford Taurus | 1999 | 2K |  May 25, 1pm | May 25, 3pm |
|  |             |      |    |  May 27, 2pm | May 27, 3pm |
|  |             |      |    | May 28, 10am | May 28, 4pm |
-----------------------------------------------------------
|3 | Ford Cortina| 1971 | 4K | etc. etc.

This is so that can easily add a SORT BY variable which will allow guests of
the website to sort the cars by either parameter.

I'm guessing I'll need to use a left inner join, and/or a GROUP BY but
that's as far as I get.

So, any ideas?

Cheers
-- 
Peder (ICQ# 105008787)

Any and all misspellings are due to a corruption of
unknown etiology.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to