How do I 'scan' all the way through an SQL table (approx 120k rows/50 columns) from the top/beginning, all the way to the bottom/end, and for each row found, I will need to 'do something'.

The 'do something' part is to search the very same SQL Table to see if a couple of columns exist more than once, and to report if any are found. I'm trying to identify duplicate rows, where the 'duplicate-ness' (!) is based upon two columns, but those two columns are not indexed.

I don't have any code examples to offer, as I'm still at the concept stage, but various different solutions have all presented the same problem in one fashion or another ... how to sequentially work down a Table and 'do something'.

The database uses SQLite; I cannot change any of the columns, but I can create/delete additional Tables.

  • 4
    What do you think a select statement does? – Colin 't Hart Jan 19 '15 at 14:13

The following query will list duplicates in a table based on 2 columns:

select <column1>, <column2>, count(*)
from <table>
group by <column1>, <column2>
having count(*) > 1;
| improve this answer | |
  • 1
    Colin, thank you for that ... your answer about how to list the duplicates was going to be the subject of a subsequent question. I tried it, and it worked. – Graham Tanner Jan 22 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.