sql - duplicate deletion problem -


i working on database have 2 tables.

bill_master (master_table)

bill_master_id
consumer_no

bill_generation (detail table)

bill_master_id

somehow user has inserted 2 identical consumer #'s in bill master bill_master_id different..here example of bill_master table

bill_master_id   consumer_no 1                1234567890 2                1234567890 

now user has made 1 transaction of bill_master_id "1" , record exists in bill_generation table.

what want when pass consumer # in sql statement parameter check if selected consumer# bill_master_id exist in bill_generation or not. if yes count return should 1 else 0.

if understand correctly, should want.

if (select count(consumer_no) bill_master m      inner join bill_generation g on m.bill_master_id=g.bill_master_id     consumer_no=1234567890    ) > 1    select 1 else    select 0 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -