Using a CASE statement

The goal is to search two similar databases for a single line of data. Smokeyphp gave me this

[php]UPDATE
regusers_test AS rt
INNER JOIN
alt_toon_test AS att
ON
att.toonname = rt.toonname
SET
rt.server = CASE WHEN rt.username=’$user’ AND rt.server=’$oserver’ AND rt.toonname=’$otoon’ THEN ‘$server’ ELSE rt.server
att.server = CASE WHEN att.username=’$user’ AND att.server=’$oserver’ AND att.toonname=’$otoon’ THEN ‘$server’ ELSE att.server
WHERE
(
rt.username=’$user’ AND rt.server=’$oserver’ AND rt.toonname=’$otoon’
)
OR
(
att.username=’$user’ AND att.server=’$oserver’ AND att.toonname=’$otoon’
)[/php]

But i keep getting:

You have an error in your SQL syntax; check the manual that corresponds to your mySQL server version for the right syntax to use near 'att.'server'=Case When att.'username'='$user'...

I did a lot of google searches over the weekend and couldn’t find a solution. Hopefully someone here knows what’s up. :slight_smile:

this must be a really tough one.

I’m using mysql 5.0

here is the ref on the manual

http://dev.mysql.com/doc/refman/5.0/en/case.html

notice that it doesn’t really help me much

Sponsor our Newsletter | Privacy Policy | Terms of Service