I am fairly new to mysql, so any bright ideas are happily welcomed.
I have a database with customer information from multiple sources. (email, name, address, phone, etc). The users email is the primary id. If a user already exists in the database, and they sign up from a new source, I want to run a function to evaluate which data i want to save, based on which entry is most recent, and which information is most complete.
email | fname | lname | home_phone | mobile_phone | source
email@domain.com | bob | smith | 1234567890 | | source1
Using the above example, if bob signed up again from a new source, only this time bob gave a mobile_phone, and NO home_phone I would want to keep the existing data with the home phone and ONLY add the mobile phone.
With INSERT ON DUPLICATE KEY UPDATE i have only been able to update the information with the new entry.
I would like to be able to possibly exit the sql query and run a php function to evaluate the data, and THEN do a sql insert on duplicate key update.
I should be able to write the php function, i just don't know how to exit a sql query and call a php function.
My apologies if I rambled, and Thank you very much if anyone has any ideas.
Thanks,
syntax
)