B Bill Norris Active Member Licensed User Longtime User Jul 6, 2012 #1 I want to read the data from two fields of a table in the database into a list, then filter out any duplicate entries in the list so that all values in the list are unique. I know I can do this with a double loop but I'm wondering if there isn't a more elegant solution?
I want to read the data from two fields of a table in the database into a list, then filter out any duplicate entries in the list so that all values in the list are unique. I know I can do this with a double loop but I'm wondering if there isn't a more elegant solution?
R Roger Garstang Well-Known Member Licensed User Longtime User Jul 6, 2012 #2 If reading from a database, use SQL to filter duplicates and give yourself good data to begin with (SELECT DISTINCT). You can even have it sorted (ORDER BY), so when you put it in your list it will be all ready to go. Last edited: Jul 6, 2012 Upvote 0
If reading from a database, use SQL to filter duplicates and give yourself good data to begin with (SELECT DISTINCT). You can even have it sorted (ORDER BY), so when you put it in your list it will be all ready to go.
B Bill Norris Active Member Licensed User Longtime User Jul 6, 2012 #3 RE: Thanks thanks -- wasn't even thinking about SELECT DISTINCT. I'm thinking now that if I use SELECT DISTINCT to populate the list with field1, then I can check each value in field2 against the list and only add if no match. Upvote 0
RE: Thanks thanks -- wasn't even thinking about SELECT DISTINCT. I'm thinking now that if I use SELECT DISTINCT to populate the list with field1, then I can check each value in field2 against the list and only add if no match.