Select DISTINCT not very useful...

Ruslan Zasukhin sunshine at public.kherson.ua
Fri Oct 24 23:22:46 CDT 2003


on 10/24/03 22:59, Michael Geary at listmail at gearyweb.com wrote:

Hi Michael,

> Hi Folks,
> 
> Can anyone explain for me how _exactly_ the DISTINCT keyword works in
> Valentina? I've got a query that returns two columns, and I want only
> to receive unique combinations. Essentially, unique rows of returned
> values. In MySQL, I can do this using GROUP BY, but that appears to
> have NO impact on my VDB. Neither does DISTINCT.
> 
> For what it's worth, here is my query. As you can see, I'm retrieving
> one column per table, and I'm interested in only unique combinations:
> 
> SELECT
> ImageMap.StructureNumber,
> structure.structurename
> 
> FROM
> ImageMap,
> structure
> 
> WHERE
> structure.structurenumber = imagemap.structurenumber
> and ImageMap.Image = '5812_3d'
> 
> ---------------
> 
> My results (in V4MD) are like this:
> 
> [#StructureNumber: 2970, #StructureName: "Gastrocnemius"],
> [#StructureNumber: 2970, #StructureName: "Gastrocnemius"],
> [#StructureNumber: 2970, #StructureName: "Gastrocnemius"],
> [#StructureNumber: 2970, #StructureName: "Gastrocnemius"],
> [#StructureNumber: 2970, #StructureName: "Gastrocnemius"],
> [#StructureNumber: 2970, #StructureName: "Gastrocnemius"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> [#StructureNumber: 92, #StructureName: "femur"],
> 
> This ought to be two hits, not several.

So what problems?
Aha, you select from 2 tables...

Try add DISTINCT after FROM keyword

FROM DISTINCT
ImageMap,
structure

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list