Add and subtract quantities from one table to another

Hello I have the following table schema:

Product:
IDProduct,
Price,
Stock,
StockAlert

Order:
IDOrder,
IDClient,

OrderDatail:
IDOrder,
IDProduct,
Price,
Quantity,
SubTotal

I need to subtract the quantity from the Product stock when making a sale … that is, subtract when the quantity field is entered in the OrderDatail table.
How can I do this?
Thx!

@ddiaz You can use the action after add configuration to do a query to the table of your choice, do the subtraction and update the table.

hi @willvin Is the syntax SQL or will it depend on the language in which it is?
Could you give me a small example please according to my data structure?
Thanks!

it depends on the project and database type.

I am with this version, 10.4.20-MariaDB

And what project type is it?

The project is with laravel vue quasar. Although we are looking at the possibility of buying the flask licenses, because they want to change the backend to python. But for now it is laravel vue the licenses that they have in my work.

Radsystems provide you with a sample snippet of code for running queries for the project types on the Page Events, by double-clicking on the snippet name it will be displayed for you. You need a basic knowledge of the backed language to use them properly. I will be providing a sample code for the Laravel Project type.

$params  = ['p_id' => $modeldata['IDProduct']];
$results = DB::select("UPDATE product SET stock = stock-1 WHERE IDProduct = :p_id", $params);

Thanks! When will the radsystems documentation be ready?

There is currently no specified time, when it is ready you will be notified, thanks.

There is currently no specified time, when it is ready you will be notified, thanks.