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')"; 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? 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. 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. Link to comment https://forums.phpfreaks.com/topic/150357-about-mysql-update-clause/#findComment-789693 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.