<p>is there an if statement when it comes to mysql query statements?</p>

<p>when i am updating a table record, i want to only update certain columns if they have a value to be updated.</p>

<p>for example, i want an update table function, and there is a table for volunteers and a table for people who just want email updates.</p>

<p>i want to use the same function (there will be a function that only deals w/ the upd queries) and is it possible to do this in theory...</p>

<p>if you are updating volunteer table, only update these columns, if mailing_list, then update these</p>

<p>i know this can by done using an if statement w/ two query statements, based on what table you're updating, but i am wondering is it possible to use only one query statement w/ the conditionals in it to update the appropriate columns in the table.</p>

<p>this may sound like something you would dream about, let me know.</p>

<p>thanks.</p>

I think this should work:
```
```
UPDATE volunteer, people
SET volunteer.email = 'me@email.com',
    people.email = 'other@gmail.com',
    people.first_name = 'first',
WHERE people.id = 2 AND volunteer.id = 5;
```
```
I got this from the
update syntax
on the MySQL website.