itzleijae Posted July 9, 2013 Share Posted July 9, 2013 (edited) The goal is to search two similar tables for a single line of data. 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' ) 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. Edited July 9, 2013 by itzleijae Quote Link to comment https://forums.phpfreaks.com/topic/280000-using-case-in-a-queryhelp/ Share on other sites More sharing options...
kicken Posted July 9, 2013 Share Posted July 9, 2013 You're missing the END for the case statement, as well as your comma between fields. 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` END , att.`server` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$server' ELSE att.`server` END WHERE (rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon') OR (att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon') Quote Link to comment https://forums.phpfreaks.com/topic/280000-using-case-in-a-queryhelp/#findComment-1440086 Share on other sites More sharing options...
itzleijae Posted July 9, 2013 Author Share Posted July 9, 2013 You're missing the END for the case statement, as well as your comma between fields. 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` END , att.`server` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$server' ELSE att.`server` END WHERE (rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon') OR (att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon') haha i derped. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/280000-using-case-in-a-queryhelp/#findComment-1440091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.