You are not selecting distinct product ids, you are selecting
distinct rows.
The 3rd field is different (category id). If you want only
distinct product
ids, you need to select distinct product ids only. If you
need the name as
well, select that. Selecting the 3rd field makes the rows
different. You can
get around it by using a MIN or MAX on the 3rd field, but
that will only
give you one of the fields (for example in product 197, you
have 2 and 11 --
you would only get 2 in the result.)
SELECT DISTINCT dbo.atblProducts.ID AS ProductID,
dbo.atblProducts.Name
AS Name, MIN(dbo.Categories.ID) AS Categories
FROM dbo.atblProducts
INNER JOIN dbo.Groups ON dbo.atblProducts.ID = dbo.Groups.pid
INNER JOIN dbo.PCat ON dbo.Groups.gid = dbo.PCat.gid
INNER JOIN dbo.Categories ON dbo.PCat.cid = dbo.Categories.ID
GROUP BY dbo.atblProducts.ID, dbo.atblProducts.Name,
dbo.Categories.ID
Tom Muck
http://www.tom-muck.com
"Lee" <lee_nospam_@artjunky.com> wrote in message
news:eog6rg$iq3$1@forums.macromedia.com...
> OK, how about a different approach.
>
> I can't seem to get a DISTINCT list of items
>
> If you look below at the results, there are duplicate
Product IDs: 197,
> 200, 200-G
>
> What is obvious is the fact that it's not actually
selecting DISTINCT rows
> of ProductID
>
> ProductID | Name | categories
> 196 | Exploring the Earth Moon System Teacher's Guide |
3
> 197 | Exploring the Human Body Teacher's Guide | 2
> 197 | Exploring the Human Body Teacher's Guide | 11
> 198 | Exploring the Earth's History Teacher's Guide | 10
> 200 | Solar System Simulator | 3
> 200 | Solar System Simulator | 38
> 200-G | Solar System Simulator (German) | 3
> 200-G | Solar System Simulator (German) | 38
>
> These results come from this query below:
> ------------------------------------------
> SELECT DISTINCT dbo.atblProducts.ID AS ProductID,
dbo.atblProducts.Name AS
> Name, dbo.Categories.ID AS Categories
> FROM dbo.atblProducts
> INNER JOIN dbo.Groups ON dbo.atblProducts.ID =
dbo.Groups.pid
> INNER JOIN dbo.PCat ON dbo.Groups.gid = dbo.PCat.gid
> INNER JOIN dbo.Categories ON dbo.PCat.cid =
dbo.Categories.ID
> GROUP BY dbo.atblProducts.ID, dbo.atblProducts.Name,
dbo.Categories.ID