Re: relational table help
| From: | Joe Brown | Date: | Mon, 30 Oct 2000 08:31:17 +0000 |
| Subject: | Re: relational table help | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4037@lists.php.net to get a copy of this message | ||
I like to use a seperate table for this join
table contact {
id,
name,
...
}
table category {
id,
catagory,
...
}
table contact_catagory {
contact_id,
catagory_id
}
insert a record into contact_catagory that points to the respective id's.
It's a little cumbersome to manage, but it's clean and fast, especially if
you have a lot of contacts/catagories.
""Shi Chuanping"" <chpshi@connection.com> wrote in message
news:003b01c04230$c9bc5400$d6e13840@pony...
> Hi,
>
> I'm not sure whether I have understand your question. But I think you
> can set a large enough field in "Contact" talbe, and call it "cat". Put
> all the category-ids of a contact into this field, and seperate them by
> comma. In your query string, you use
> "select * from contact where cat like \"%<the id>%\"".
>
> Hope this can help.
>
> Alex
>
>
> > Hello,
> >
> > I'm using PHP with MySQL on UNIX box running Apache and I need some help
> > relating two tables...
> >
> > I have a table called Contact which holds records with standard contact
> > info (ContactID [unique], Name, Add1, Add2, State, Country, Zip, URL).
> >
> > Each of these contacts falls into one or more Categories ...
> >
> > I have a Categories table (CategoryID [unique], CategoryName) ...
> >
> > And I have a CategoryContact (CategoryID, ContactID) table where I keep
> > track of which Contacts fall into which Catgeories ... so if for example
> > a Contact with a ContactID=7 qualified for Category X (which has a
> > Category ID=1) and also qualified for Category Y (which has a
> > CategoryID=2), than there would be to rows in CatgeoryContact ... 7,1
> > and 7,2.
> >
> > How do I display all the Contacts that qualify for a particular
> > Category?
> >
> > Please help!
> >
> > Thanks,
> >
> > Nick
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-db-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>