List:General Discussion« Previous MessageNext Message »
From:Aveek Misra Date:May 17 2011 7:53am
Subject:Help with a query
View as plain text  
I have a table A and table B of the same type as

CREATE TABLE A (
     `file` varbinary(255) not null,
     `digest` binary(40) not null
)

CREATE TABLE B (
     `file` varbinary(255) not null,
     `digest` binary(40) not null
)

I have another table C of the following type 

CREATE TABLE C (
     `file` varbinary(255) not null,
     `digest` binary(40) not null,
    `refcount` bigint(20) not null
)

I need to write a query where for the same file and digest in table A and table B, the
refcount is table C is not the same. So:

SELECT COUNT(*) as count 1 FROM A WHERE file='file1' AND digest='digest1';
SELECT COUNT(*) as count 2 FROM B WHERE file='file1' AND digest='digest1';

and then adding up the two counts from these queries and comparing it with the result of
the following query:

SELECT refcount FROM C WHERE file='file1' AND digest='digest1';

basically (refcount == (count1 + count2)) should be true and I am interested in finding
out all such records in table C where this is not the case.



Thanks
Aveek
Thread
Help with a queryAveek Misra17 May
  • Re: Help with a queryAnupam Karmarkar20 May
    • Re: Help with a queryAveek Misra20 May