Here is my table:
Id Name Count
1 Apple 1
2 Peach 1
If I just have Name and MySql which is set to "Safe Update Mode"(under this mode, can't update table with out key in where terms). So I need get Id by Name at first, then update row.
In SqlServer, I can do it like below:
DELCARE @Id INT;
SELECT @Id=(SELECT Id FROM MyTable WHERE Name='Apple')
IF(@Id IS NOT NULL)
BEGIN
UPDATE MyTable
SET Count=2
WHERE Id=@Id
END
In MySql, how can I do?