I have 2 databases, one for the operations and one for analytics.
The analytics database is not 1:1 the same as the operations database but still very similar.
Now I loaded archive files (csv) into the analytics database (it was empty before).
I have my old data in the analytics and my current data in the operations database.
I want to write a query to find out if some of the newly loaded records were already in the database.
Is there a way to check this out?
EDIT:
First of all I'm sorry. Made a mistake after looking at my database. I don't need to compare two different databases, while copying the operations database via phpmyadmin I forgot to load the current data into the analytics database. So I just need to compare 2 tables in one database, whether some of the old records were already in the database.
My first idea is/was:
SELECT *
FROM orderlinesold t1
LEFT JOIN orderlines t2 on t1.orderid = t2.orderid;
but after running that query I get the hole rows as a result which is impossible --> wrong query.
How can I check up if some of the old data are still in the new one?
PS: Tables are in the comments as a link.
- EDIT:
Ok I solved it. Was just a little comparing query:
SELECT *
FROM ordersold t1
INNER JOIN orders t2 ON t1.orderid = t2.orderid
LIMIT 100000000;
or:
SELECT *
FROM orderlinesold t1
LEFT JOIN orderlines t2 ON t1.orderid = t2.orderid
WHERE t2.orderid IS NOT NULL
LIMIT 100000000;
Both discard the correct result.
Still thanks. This post can be closed.