Click to See Complete Forum and Search --> : Can anyone help with this query?


itbeings
03-27-2007, 08:01 AM
I want to return a distinct Main Category from the 'mcat' table with it Sub-Categories from the 'scat' table but am getting online one sub-category returned. Any one ?

SELECT DISTINCT mc.mcatID, mc.mcatName, sc.scatID, sc.scatName FROM mcat mc
INNER JOIN scat sc
ON mc.mcatID = sc.mcatID

potterd64
03-28-2007, 02:02 PM
probably something wrong with your tables. The query looks fine, and should work as long as the tables are setup correctly. There are supposed to be multiple sub category entries per main category entries right?

Phill Pafford
03-28-2007, 02:02 PM
I think its your SELECT DISTINCT, this should only return one record and in the statement it reads for all the tables.

itbeings
03-28-2007, 09:03 PM
All I want to do is get a main category and it's sub categories returned in a single query. On the sub-category table, I have the main category PK(mcatID) as FK(mcatID). All I want is just a single Main Cat.. and all its sub cat returned.