mysqlÖÐÔõôÐÞ¸ÄijһÐÐ
mysql ÖÐÐÞ¸ÄÒ»ÐÐÊý¾ÝµÄÓ﷨Ϊ£ºupdate table_name set column1 = value1, column2 = value2, … where condition;¡£ÆäÖУ¬conditionÓÃÓÚΨһ±êʶҪÐ޸ĵÄÐУ¬value1¡¢value2 … ÊÇеÄÁÐÖµ¡£×¢ÖØÈ·±£conditionÖ¸¶¨Î¨Ò»±êʶ·û£¬²»È»¿ÉÄÜÒâÍâ¸üжàÐС£ÑéÖ¤¸ü¸Ä¿ÉÒÔʹÓÃselectÓï¾ä¡£
ÔõÑùÐÞ¸Ä MySQL ÖеÄijһÐÐ
ÔÚ MySQL ÖÐÐÞ¸ÄÒ»ÐÐÊý¾ÝµÄÓï·¨ÈçÏ£º
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
µÇ¼ºó¸´ÖÆ
ÆäÖУº
table_name ÊÇÒª¸üеıíÃû¡£
column1, column2, … ÊÇÒª¸üеÄÁÐÃû¡£
value1, value2, … ÊÇÐÂÖµ¡£
condition ÊÇÓÃÓÚÈ·¶¨Òª¸üÐÂÐеÄÌõ¼þ¡£
ʹÓÃʾÀý
ÒÔÏÂʾÀý¸üРusers ±íÖÐ id Ϊ 5 µÄÐÐµÄ name ºÍ email ÁУº
UPDATE users SET name = 'John Doe', email = 'johndoe@example.com' WHERE id = 5;
µÇ¼ºó¸´ÖÆ
×¢ÖØÊÂÏî
È·±£ condition Ö¸¶¨Ò»¸öΨһ±êʶ·û£¬ÒÔ×èÖ¹ÒâÍâ¸üжà¸öÐС£
ÈôÊÇ condition ²»Öª×ãÈκÎÐУ¬Ôò²»»á¸üÐÂÈκÎÊý¾Ý¡£
ÈôÊÇÖ¸¶¨µÄֵΥ·´Ô¼Êø£¨ÀýÈ磬Ö÷¼ü»ò·Ç¿ÕÁУ©£¬Ôò»áÒý·¢¹ýʧ¡£
¸üÐÂÐк󣬿ÉÒÔʹÓà SELECT Óï¾äÑéÖ¤¸ü¸Ä¡£
ÒÔÉϾÍÊÇmysqlÖÐÔõôÐÞ¸ÄijһÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡