Show only new and removed records by comparing to MySQL tables
Hello all;
I have been really frustrated with finding the correct perl code (and MySql statements) to accomplish what I thought was straight forward...I have tested I don't know how many different codes\suggestions I found on the net without any success...but anyhow let me explain my plight and what I am looking for...
I have 2 tables (in same db called audit)
Table 1:
Table 2:
So what my code does right now is:
1. copies all records from permchk_violations to permchk_violations_tmp
2. truncates permchk_violations so that it's ready to be populated with more data
3. goes and gets data and populates permchk_violations
4. This is what I need help with - I am suppose to check the newly populated permchk_violations table to the data that was copied to the permchk_violations_tmp table earlier...what I want from this comparison is to do the following:
a. find records that exist in permchk_violations but NOT IN permchk_violations_tmp; write these records to another table (let's call it permchk_violations_new)
b. find records that exist permchk_violations_tmp but NOT IN permchk_violations; write these records to another table (let's call it permchk_violations_removed)
IMPORTANT: I do not care about records that may be "altered" (ie a field changed it's value)
ASSUMPTION: the two tables permchk_violations_new and permchk_violations_removed will have the same field structure as the other two tables I have shown.
So this is my dilemma..hope someone can assist ASAP...I need to get this perl script into production in 1 week's time.
If you need further information please let me know.
Thanks in advance.
Last edited by Franklin52; 05-31-2012 at 03:47 AM..
Reason: Please use code tags for data and code samples
I have defined a set of global variables at the beginning of my script as below:
#ideal values
export ITEM1=SUCCESS
export ITEM2=FAILURE
export ITEM3=UNAVAILABLE
export ITEM5=FAILURE
export ITEM6=SUCCESS
now I have a shell script function which returns a value in below format.
ITEM1... (1 Reply)
my queryis :
select distinct m.name, item_count, item from master m join client p on m.name=p.name where item_count = 1 and item > 1;
But how should I update them?
i used update statetment :
Update from client Set item =1 where m.name=p.name and item_count=1 AND item>1
Is this wrong? (1 Reply)
Hello;
I want merge four MySQL tables to get the intersection that have a common field for all of them. Join two tables is fine to me, but my this case is different from common situations and there are not very many discussions about it. Can anybody give me some idea? Thanks a lot!
Here is part... (8 Replies)
Hello everybody,
I'm having troubles creating a relation between two tables in a MySQL database.
Having two tables, being one which contains users information (username, password, user ID, etc) and the other the one which contains transactions information (operation type, user ID of the user who... (2 Replies)
Hi,
I have two databases with same tables on different servers.I need to check the data content in each table and if something is missing, should print that.
I have a tool which takes the snapshot the table structure,index so on and compares with the other server tables snapshot.
Now i need... (1 Reply)
Hi all,
I have 2 mysql databases running on two different servers (both can be accessed via ssh to each other).
If I have say table ABC on server 1, how can I sync it with table ABC on server 2 if the number of records is different? Both databases are the same structure though server 2 has... (2 Replies)
I am comparing two table structure in different databases,Put into 2 txt files , when comparing if column sequnce and data type is not matching ,it has to display that info else Table structure is ok.
wrote shell script ,its not working .I am getting "Table structure is not ok" even if both... (1 Reply)