I have a large database that is updated daily. I am trying to pass a subset of data from one table to another within the database. It's a real estate site and I am trying to create a smaller table to work with houses from a certain office from within all the data.
I can do an insert:
$query = "INSERT INTO table2 SELECT * FROM table1 WHERE officeid = 'xxx'";
But what I want to do is set it so that my script evaluates each record, checks whether it exists in table2, if it does, it updates it, if it doesn't, it inserts it. Is there a way to do this with if ... else or am I just thinking wishfully.
I would be delighted to read up on this if someone could help me figure out the right Google query, I've tried but to no avail.