Posted by ZeldorBlat on 12/09/06 21:28
Dave Nash wrote:
> Thanks Aho
>
> So how do I get the data from a db.
> I have retrieved the category listings with this
>
> "SELECT * FROM categories" which gives me a page with the categories
> and links to a a page called listitems.php
>
> What I cant work out is how to view all of the items once i click on a
> category that match the category id in the relational table.
>
> thanks again.
>
>
>
>
> On Sat, 09 Dec 2006 13:55:44 +0100, "J.O. Aho" <user@example.net>
> wrote:
>
> >Dave Nash wrote:
> >> hi All,
> >>
> >> I have created a database with two tables, categories and items.
> >>
> >> How do I go about assigning a particular item to more than one
> >> category?
> >>
> >>
> >> <Categories table>
> >> Catid
> >> Catname
> >>
> >> <Items table>
> >> Itemid
> >> itemname
> >
> >Create a relation table
> >
> ><ItemCat table>
> >Itemid
> >Catid
> >
> >
> > //Aho
Get all the items that belong to catid 5:
select i.itemid, i.itemname
from item i
join ItemCat ic
on i.itemid = ic.itemid
where ic.catid = 5
[Back to original message]
|