S
S
SergeyNN2018-05-16 19:41:46
MySQL
SergeyNN, 2018-05-16 19:41:46

How to get FALSE on UPDATE in MySQL if query failed due to invalid conditions?

Good afternoon.
I work in MySQL 5.6. When I do

UPDATE `table` SET `value` = 'new_value' WHERE `id` = 0
if there is no row with id = 0, then TRUE is returned, although the update obviously did not occur.
I would like to see FALSE.
What settings can be added to the server configuration?
Please advise how to proceed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-05-16
@SergeyNN

A completed query that hasn't changed any rows is still a successful query.
If you want to make separate logic in case of a query that did not change a single row, check affected rows after the query .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question