I managed to import a whole load of xml files into database table called "trans" with the help from here: Extracting XML data into MySQL
I wanted to create some additional checks, importing unique xml>database, also delete anything that is in the database that doesn't match from database>xml, keep a list of all non matching entries.
I have managed to get xml>database check to work, importing only unique new transactions.
But sometimes at month end I need to check if the database is still up to date with a new up to date monthly xml file. I need to list everything that does not match the new xml an again to delete them.
How can one achieve this using PHP?
Current Database
custID Name Product
2 john P2
8 mark P3
9 craig P3
New XML
custID Name Product
2 john P2
7 sarah P4
Expected Updated Database
custID Name Product
2 john P2
7 sarah P4
Database does not match xml
custID Name Product
8 mark P3
9 craig P3
The only thing I can come up with is to get non matching entries in database is to do a left outer join and locate using null values.
Is this the right way or is there a simpler way or more elegant way to do it?
Here's the select statement
select a.custID, b.custID from trans a
left outer join transtemp b on b.custID=a.custID
where b.custID IS NULL