SQL to update a table only if that table exists in the database

mysql, sql-update

Solution

Just run the update statement, if the table didn't exist, it will fail and cause no damage.

Problem

I have a mySQL database that might have a table named `jason`. A separate instance of the database may not have the `jason` table (it would have other tables in common) I'd like to run a simple update against both databases but the update is for the `jason` table. I know I can do something like ``` DROP TABLE IF EXISTS `jason`; ``` Is it possible to run an Update something like: ``` IF EXISTS `jason` UPDATE `jason` SET... ``` I can't seem to get anything to work.

Original source