Reputation: 147
using vb 2010 on an access database
INSERT INTO UniqueTable
SELECT DISTINCT
1,2,3,4,5
FROM DataTable
This will get only unique rows in all fields and if I only specify the one field I want to be distinct it only inserts the data in that field
How can I import all data from every field where field 5 is unique?
If I set the database field properties to not allow duplicates all import fails.
Thanks
Upvotes: 0
Views: 274
Reputation: 89285
Don't use distinct in this case, you can't specify which field need to be distinct, it works for entire columns selected. Use group by instead, like: ..GROUP BY 5 .. HAVING COUNT(*) = 1
. That will return all rows having field 5 value appear only once in the table, in other word distinct.
Upvotes: 1