Re: Querying two tables

From: Date: Mon, 16 Dec 2002 12:38:15 +0000
Subject: Re: Querying two tables
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-24170@lists.php.net to get a copy of this message
Cesar Aracena wrote:
Table 1 - Categories catid (autonum) catname Table 2 - Sub categories subcatid (autonum) subcatname Table 3 - Products prodid (autonum) prodname Table 4 - Relationships Catid Subcatid Prodid Now, the question is how to fetch all the sub-categories let's say that are related to category 0001. I know it's as simple as relating two tables in one query, but I don't remember how. Any help appreciated.
select distinct subcategories.* from subcategories s, relationships r where r.catid = '0001' and s.subcatid = r.subcatid

« previous php.db (#24170) next »