in reply to Dumb SQL Question

This works in SQLite:
select * from files where md5 in (select md5 from files group by md5 having count(*)>1)

No need for a second table.

Replies are listed 'Best First'.
Re^2: Dumb SQL Question
by pileofrogs (Priest) on Mar 02, 2010 at 21:04 UTC

    Woo Hoo! That did it!

    Correct, once the values are in the DB, I only would need the md5s table to print the md5s, which I really don't need to do. The md5 id in the files table is adequate for my purpose.

    Using your suggestion as a jumping off place, I made this final query which does eveything, including the unnecessary printing of the MD5 sum.

    select files.path,md5s.md5 from files,md5s where files.md5 in ( select files.md5 from files group by files.md5 having count(*)>1 ) AND md5s.id=files.md5 order by files.md5;

    Thank You!
    --Pileofrogs

    Update: forgot the "order by". It was in the query when I ran it but fell out when I re-typed it here... D'oh! Thanks bart!

      You can print results in groups of the same files, if you add an "ORDER BY" clause. Personally I prefer to sort by file size, if you store it, but you can use "MD5" as well.