The use of MySQL update
Can I use subqueries in UPDATE statements for MySQL?
Update score Set name = ' Harry ' where total score = (select min (total score) from score);
Why do I go wrong with this?
/*******************
CREATE TABLE IF not EXISTS score (
Study number BIGINT UNSIGNED,
Name varchar (10),
Mathematics TINYINT UNSIGNED,
English TINYINT UNSIGNED,
Physical TINYINT UNSIGNED,
Computer synthesis TINYINT UNSIGNED,
Total score int UNSIGNED
);
ensured that each field data is inserted correctly
********************/
For advice
------Solution--------------------
Try this,
Update score set ... where total score in (SELECT * FROM (select min (total score) as total from score) T)
------Solution--------------------
SQL Code
Update score Set name = ' Harry ' ORDER by total score ASC limit 1;
------Solution--------------------
MySQL Update table can not appear in the first layer of subqueries, refer to the 4 floor method to bypass the first layer of subqueries
------Solution--------------------
Try it, you know.
SQL Code
UPDATE Score