[thelist] SQL (or ASP?) selecting from a multi-valued column
Elfur Logadottir
elfur at lists.evolt.org
Mon Feb 5 19:35:37 CST 2001
Man, I was hitting the sac, when your email came through ...
and now I have to keep on.
From: "rudy" <r937 at interlog.com>
| this is okay too, but let's stop right here and ask a few
questions
| can a news article belong to more than one category?
yes
| or is a news article always always always in *at most* one
category?
no
| you didn't actually say what your categories are, but i'm
going to take a
| guess that a news article might be in more than one
category
you're right
| the way to implement a many-to-many relationship is with
two one-to-many
| relationships
|
| let's take a closer look
|
| here are three tables
|
| category (catID, catname)
|
| newsitem (newsID, newsname)
|
| newscat (newsID, catID)
|
| let's populate them with some example rows
<snipping some *great* example rows ...>
| these two one-to-many relationships implement the
many-to-many relationship
| between news items and categories
|
| take it slow and easy, elfur, and i'm sure it will make
sense real soon
I actually got it, almost right away ... thank you rudy.
| you should now be able to see the sql for selecting, say,
all the news
| items in a particular category
|
| for example, to get all the entertainment news items,
|
| select newsname
| from newscat, newsitem
| where newscat.catID="3"
| and newscat.newsID=newsitem.newsID
|
| holler if you need more
oh, believe you me, I'm going to need some more, but I think
this is the time to take it offline
thanks a bunch rudy
elfur
*the not so frustrated one*
More information about the thelist
mailing list