MySQL/Cross checking Databases in mySQL
Expert: stuart gregory - 9/28/2009
QuestionHi,
I'll preface this by saying that I haven't with a command line in any way shape or form in years, so please feel free to spell everything out for me. Please!
With that out of the way, I have to cross-check data in mysql tables. One column is last month's entries, and the second is this month's entries and I'm simply looking for repeat entries to be exported to a new database.
So. . . how do is this done?
AnswerDear Sir
I'm not fully sure what you mean here but heres what i think you mean, please correct me if i am wrong.
You want a script to check last months entries, agaist this months entries if there is a match move to new database table
or do you mean if there is more than one entry the same in either last month or this month move to new database table so last month and this month only have unique entries in them?
either on of these situations could be written witha simple PHP script, A while loop selects each entry in the table then for each entry find the number of rows that match a key term, then if MySQL number of rows = > 1 you then need a script to move the table contents to another table,
Now continue with the loop for the next entry.
Before writting such a script it is advisable to write a simple structured english statment of what the script should do and they work through it step by step. once each step works continue to the next step rather than trying to write the script all in one go.
Try using
http://www.web-application-development.info as a refrence point for scripts plus they have a new forum there dedicated for script help