473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to find difference between multiple tables and all their fields

dlite922
1,584 Expert 1GB
Short Version
How do you find the difference between two database with the same structure but different data? with SQL (results will be ingested with PHP).

Long Version
Seems like a little daunting task for a SQL n00b like me, but I'm here to seek some guidance and clear my head from all the googling.

I thought this would be common thing to do. I have two "database dumps" at different times, I want to know what data is different between them. I can do a check sum and know they're different, but I want to get those exact fields that different.

For this purpose, say there are 3 main tables
events: list of tv shows and movies
actors: list of actors in those movies and shows
image: image of the actors and tv shows and movie logos
*connector tables*: A few tables that connect all of these together.
Between two dumps of these tables, there could be new events, new actors, some actors with changed IDs, or just changes names (rare), and of course new images, but please note i'm not just talking added or deleted records, there could be changes to the data. I.e. same image ID, but now has a different image name, or same actor ID, but a middle initial is added, etc.

I want to display these differences with mysql queries.

INNER JOINS? some tool or procedure script?

Any direction appreciated,



Dan
Apr 20 '10 #1
4 4757
code green
1,726 Expert 1GB
I would be tempted to do this via code. You mention PHP.
I have done similar projects and retrieved the data from each database in seperate queries,
then manipulated the data into arrays and compared the arrays.
You have much more flexibility for creating reports this way, and if you wish to update from one to the other, the data can be easily manipulated into an UPDATE or INSERT statement
Apr 21 '10 #2
dlite922
1,584 Expert 1GB
Problem is these tables are huge, approaching millions.

Could take a lot longer with code.

I can't believe MySQL doesn't provide a open source diff report/script between two DBs.

How does a DBA quickly finds the difference between two database dumps?




Dan
Apr 21 '10 #3
Annalyzer
122 100+
@dlite922
Can't you use something like

SELECT *
FROM table1 INNER JOIN table2 ON table1.id=table2.id
WHERE table1.field1 != table2.field1 OR table1.field2 != table2.field2...
Apr 21 '10 #4
code green
1,726 Expert 1GB
I am not aware of anything. I spotted a couple of tools on Google
SQLyog
Maatkit.
red-gate's SQL Compare (Commercial)
liquibase
Toad
Nob Hill Database Compare
MySQL Diff
Performance-wise with code, it all depends.
If a lot of fields are text then string comparisons are painfully slow in SQL.
Apr 22 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Gleep | last post by:
sorry i didn't explain it correctly before my table is like this example fields: ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..) I know that...
16
by: Justin Hoffman | last post by:
This is a question concerning query optimisation. Sorry if it's a bit long, but thanks to anyone who has the patience to help - This is my first post here... If I have two tables:...
7
by: Michael Deathya | last post by:
Hi, I am pulling over 400 different metrics from an Excel spreadsheet into Access (97). Conceptually, each row represents a single set of these 400 metrics. However, because of the 255 column...
1
by: Brian | last post by:
I'm trying to find a way to search multiple tables for the same record. Say I have 3 tables all with a name column, I need to search all 3 tables and find matching names. Is there an easy way to...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
1
by: Brian | last post by:
I have a dataset containing 2 tables. I need to fill a datagrid using data from both of these. If I could create a SQL Statement to fill the datagrid, it would look like this: SELECT...
13
by: ricky.agrawal | last post by:
I'm really not sure how to go about this in Access. What I've created is a table for each location. Those tables are identical in format but different in information. The tables are named after...
6
by: ApexData | last post by:
I have 2 tables: Table1 and Table2. Neither one has a primary key because each table will only have 1-record. My form is a SingleForm unbound with tabs (my desire here). Using this form, in...
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
3
by: DeanL | last post by:
Hi guys, Does anyone know of a way to create multiple tables using information stored in one table? I have a table with 4 columns (TableName, ColumnName, DataType, DataSize) and wanted to know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.