aebstract Posted April 13, 2010 Share Posted April 13, 2010 I'm needing to update a column in my database, basically I have two tables: participants: id regid cr registrations: id class The id columns are unique int values. The regid = registrations.id I need to update the cr record for every row where the regid's class = "whatever". This would be a piece of cake for me if I was just grabbing information, but I'm not so sure about updating the field. Quote Link to comment https://forums.phpfreaks.com/topic/198430-can-i-do-this-in-one-query/ Share on other sites More sharing options...
aebstract Posted April 13, 2010 Author Share Posted April 13, 2010 mysql_query("UPDATE participants SET participants.cr = 'ql' JOIN registrations ON registrations.id = participants.regid WHERE registrations.class = '$_GET[class]' && participants.eventid = '$_GET[event]'") or die(mysql_error()); 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 'JOIN registrations ON registrations.id = participants.regid WHERE registrations.' at line 1 So that I'm not just asking for it to be written for me. I will be working on this code. Quote Link to comment https://forums.phpfreaks.com/topic/198430-can-i-do-this-in-one-query/#findComment-1041238 Share on other sites More sharing options...
aebstract Posted April 14, 2010 Author Share Posted April 14, 2010 bump ? Quote Link to comment https://forums.phpfreaks.com/topic/198430-can-i-do-this-in-one-query/#findComment-1041579 Share on other sites More sharing options...
aebstract Posted April 14, 2010 Author Share Posted April 14, 2010 mysql_query("UPDATE participants t1 JOIN registrations t2 ON (t1.regid = t2.id) SET cr = 'ql' WHERE class = '$_GET[class]' && eventid = '$_GET[event]'") or die(mysql_error()); Currently look like this, getting this error: 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 '' at line 1 If I remove the single quotes from the FROM section, I get this error: 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 '10.5 && eventid = 2' at line 1 When you remove the '' around ql I get: Unknown column 'ql' in 'field list' Quote Link to comment https://forums.phpfreaks.com/topic/198430-can-i-do-this-in-one-query/#findComment-1041606 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.