Hello Experts,

I have following tables:

Table_1:

C_ID Inst_No Paid_Dt
201 2 12/06/2010
202 2 13/06/2010
203 3 12/06/2010
202 3 16/06/2010


Table_2:

C_ID Inst_No Today_Dt
201 2 12/06/2010
202 2 12/06/2010
203 3 12/06/2010
202 3 16/06/2010


Now, from the above two tables I want to display only the records where Paid_Dt and Today_Dt are not equal.

Like the Result should be
202 2 12/06/2010

I tried it by inner join and <> (Not Equal operator) but, it shows all data instead of a particular.

Recommended Answers

All 2 Replies

Hello,

What you need to do is to select your records and do the join with the C_ID and Inst_No and then use the WHERE to select a subset of the data where the fields are not equal. Something like:

SELECT Table_1.C_ID, 
Table_1.Inst_No,  
Table_1.Paid_Dt, 
Table_2.C_ID 
Table_2.Inst_No 
Table_2.Today_Dt
From Table_1 Inner Join Table_2 on Table_1.C_ID = Table_2.C_ID 
AND
Table_1.Inst_No = Table_2.Inst_No
WHERE 
Table_1.Paid_Dt <> Table_2.Today_Dt

Thanks a lot, My problem is solved. Now I am getting the result what i was looking for.

Regards!!

Hello,

What you need to do is to select your records and do the join with the C_ID and Inst_No and then use the WHERE to select a subset of the data where the fields are not equal. Something like:

SELECT Table_1.C_ID, 
Table_1.Inst_No,  
Table_1.Paid_Dt, 
Table_2.C_ID 
Table_2.Inst_No 
Table_2.Today_Dt
From Table_1 Inner Join Table_2 on Table_1.C_ID = Table_2.C_ID 
AND
Table_1.Inst_No = Table_2.Inst_No
WHERE 
Table_1.Paid_Dt <> Table_2.Today_Dt
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.