Forum > Databases

How to get a list of unique values for a given column from TDataset

(1/2) > >>

stoffman:
Hi,

Is there a "standard" way to get all the unique values for a given column in TDataset? I can loop my self and find them, but I'm sure I'm not the first one to encounter this problem so I'm looking for more official way.

EDIT: To be sure the data source is not a database, and I explicitly wish to achieve this with data already loaded into a dataset   

Thanks,

SymbolicFrank:
I would add them to a TStringList with duplicates turned off.

devEric69:
Depending on the database, the SQL keyword DISTINCT or DISCTINCTROW exists.

Zvoni:
Nevermind, if that column is already defined as "UNIQUE" then you just SELECT it, since the DB enforces uniqueness of values for that column

stoffman:
@zvoni @devEric69

The data source is not a database.

@SymbolicFrank

That seems like an option. Are there any alternative (assuming the column is not a string and I would like to avoid the conversion) ?

Navigation

[0] Message Index

[#] Next page

Go to full version