There are 2 tables both tables having the same columns(id, name,salary). The salary of Table 2 is changed for some id's. Now I want the data for those whose salary is different from Table 1.
I tried this but not success. Please someone help me.
Wouldn't it be easier to just join the two tables and use a where-clause to only include the matched records which have different salary values? As a general rule you should always prefer having the database engine do that sort of logic rather than writing Java code to do it.
Do this in the database with SQL, not in Java. Depending which database you're on, you may be able to use set operators to make it easier. Using SQL to run the query in the database means you don't have to move all the data across the network, you can use a proper query language, and the query engine can take advantage of any indexes to improve performance.