Is it possible to increment a value in MySql field without first having to query the original value?

Hey all,

I typically QUERY the DB for data, then I’ll do an UPDATE on that value, and add the value want to add.

I’ve been doing some research and it seems that it’s possible to do this without first running a QUERY, this would be optimum and save a lot of resources over time I imagine.

Here’s the post

For the Wappler experts out there - is this possible to do within Wappler, using the DB Manager and UI - and without any custom work?

I think you can just use the query as in your link, eg:
UPDATE myTable SET myField = MyField + 1 WHERE id = 1234
… using a custom query.
I"m not sure where the DB manager comes in, but I don’t think any custom work is needed (except the custom query).

Thanks @TomD, I have not used custom queries before so not confident there. I was hoping this might be doable without.

There is no way you know what the value you are updating with the database updater is, without querying the table first. And you need to know it in order to add +1 to it.
As Tom explains, you can do this using a custom query like

UPDATE test_update 
SET myval = myval + 1
WHERE id = :P1

Screenshot 2021-02-11 at 14.11.37

Just set the :P1 value to whatever expression you need.