I compared table1 data table2 data, and filtered data which was not existed in table1. I want to make both tables rows count equal. For that, I need to set is_active = 0 in table2, where the data was not existed in table1.
Example::
UPDATE table2
SET table2.is_active = 0
WHERE (SELECT table2.user_name
FROM table2
WHERE table2.is_Active = 1
AND table2.user_name NOT IN (SELECT table1.user_name
FROM table1
WHERE table1.is_Active = 1));
==table1== ==table2==
'A', 'B', 'C' 'A', 'B', 'C'
'A', 'E', 'C' 'M', 'N', 'O'
'A', 'E', 'D' 'A', 'E', 'D'
'A', 'E', 'D'
In above example, table 1 and table2 contains similar data except 'M', 'N', 'O', I want set this row into is_active = 0 state.