android - Query based on the difference in number of occurrences in other tables -
i have 3 tables.
table_main: +-----+----------+-------------+ | _id | entry_id | info | +-----+----------+-------------+ | 1 | a1 | info 1 | | 2 | a2 | info 2 | | 3 | a3 | info 3 | +-----+----------+-------------+
table_additions:
+----------+-----------+ | entry_id | timestamp | +----------+-----------+ | a1 | 123456 | | a2 | 123458 | | a1 | 123654 | | a1 | 123658 | | a2 | 123843 | | a3 | 123911 | +----------+-----------+
table_deletions:
+----------+-----------+ | entry_id | timestamp | +----------+-----------+ | a3 | 123556 | | a2 | 123558 | | a3 | 123754 | | a1 | 123858 | | a3 | 123863 | | a3 | 123976 | +----------+-----------+
i working in android. want info table_main
of entries have :
number of occurances in table_additions
> number of occurances in table_deletions
so, in above example, output should be:
+-----+----------+-------------+ | _id | entry_id | info | +-----+----------+-------------+ | 1 | a1 | info 1 | | 2 | a2 | info 2 | +-----+----------+-------------+
this can done correlated subqueries:
select * table_main (select count(*) table_additions entry_id = table_main.entry_id ) > (select count(*) table_deletions entry_id = table_main.entry_id )
android sqlite android-sqlite
No comments:
Post a Comment