I'm having a numtpy SQL/Table moment
I'm having a numtpy SQL/Table moment
Author
Discussion

cuneus

Original Poster:

5,963 posts

270 months

Friday 14th September 2007
quotequote all
Some help please

Table - Cars has a unique key of Carnumber
Table - Articles has a unique key of Articlenumber (sometimes about 1 or many cars)

What I want to be able to do is show all the articles related to a single car

How ?

TIA

selwonk

2,143 posts

253 months

Friday 14th September 2007
quotequote all
Presuming you've got something similar to this:

Cars
CarsID
...

Articles
ArticlesID
CarsID
...

SELECT [fields] FROM Articles WHERE CarsID=x;

HTH

cuneus

Original Poster:

5,963 posts

270 months

Friday 14th September 2007
quotequote all
Yes it does - the only small problem is that where an article contains multiple cars the article info will be repeated - so I'll ship that into a separate table

Thanks

selwonk

2,143 posts

253 months

Friday 14th September 2007
quotequote all
Sorry - I'd clearly not read your original question properly frown

selwonk

2,143 posts

253 months

Friday 14th September 2007
quotequote all
Are you using mySQL?

selwonk

2,143 posts

253 months

Friday 14th September 2007
quotequote all
I'm not sure if I've understood what the problem is. However, have a look in google for "SELECT DISTINCT" which should help you to suppress duplicate rows...

cuneus

Original Poster:

5,963 posts

270 months

Friday 14th September 2007
quotequote all
selwonk said:
Are you using mySQL?
No

cuneus

Original Poster:

5,963 posts

270 months

Friday 14th September 2007
quotequote all
selwonk said:
I'm not sure if I've understood what the problem is. However, have a look in google for "SELECT DISTINCT" which should help you to suppress duplicate rows...
Will do


zaktoo

805 posts

235 months

Friday 14th September 2007
quotequote all
If you want more flexibility, have tables "cars", "articles", and a "CarsToArticles" table. That way, there's a many to many relationship possible.

HTH

Ciao

Zak

cuneus

Original Poster:

5,963 posts

270 months

Friday 14th September 2007
quotequote all
zaktoo said:
If you want more flexibility, have tables "cars", "articles", and a "CarsToArticles" table. That way, there's a many to many relationship possible.

HTH

Ciao

Zak
Yes! that's the bit I couldn't get my head round - nearly there now

Ta