weekenthe9 Posted March 20, 2009 Share Posted March 20, 2009 How can you update multiple columns together? Does this work? $query = "UPDATE ".$table_name." SET (`Field1`, `Field2`, `Field3`) VALUES ('$Value1', '$Value2', '$Value3')"; Quote Link to comment https://forums.phpfreaks.com/topic/150357-about-mysql-update-clause/ Share on other sites More sharing options...
Maq Posted March 20, 2009 Share Posted March 20, 2009 What makes you think that it won't work, did you try it? Quote Link to comment https://forums.phpfreaks.com/topic/150357-about-mysql-update-clause/#findComment-789659 Share on other sites More sharing options...
weekenthe9 Posted March 20, 2009 Author Share Posted March 20, 2009 This is the query I was trying: UPDATE comments_test SET (`user`, `comment_Link`, `Project_Key`) VALUES ('A', 'B', '12') WHERE `Key`='6' But it gives an error message saying: ERROR 1064: You have an error in your SQL syntax. Quote Link to comment https://forums.phpfreaks.com/topic/150357-about-mysql-update-clause/#findComment-789687 Share on other sites More sharing options...
Maq Posted March 20, 2009 Share Posted March 20, 2009 Most people use UPDATE like this: $sql = "UPDATE comments_test SET user = 'A', comment_Link = 'B', Project_Key = 12 WHERE Key=6;" echo "Your query: " . $sql; mysql_query($sql) or die(mysql_error()); Although I think you can use the syntax you were trying. Quote Link to comment https://forums.phpfreaks.com/topic/150357-about-mysql-update-clause/#findComment-789693 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.