Subtracting Values from two different SQL database

Hey everyone,
I'm very new to ignition, mysql, and coding itself. I'm trying to create button that will allow me to add/minus the value of one table column from another table column. I created an ID in each row for both tables to allow me to reference which specific value in the column I want to add/minus from. Both tables are binded to a MySQL database. I was wondering if someone could help me out with this button function and if this button creation is possible to create.
Thank you!

You will need to query them separately (in query bindings) then use an expression binding. This would be suitable for display, in a label, perhaps.

What do you want the button to do?

Thank you for the reply pturmel,
The goal of the button is whenever I click on it, it will add the value of one sql database to the other sql database. I shared an image to show what I mean.


You could also do this in a Mysql query and display the results in the same manner.


Not clear. Please show:

  • The display you wish before the button is pressed, and
  • the display you wish after the button is pressed, and
  • the state of the tables before and after.

So the highlighted numeric field entry updates the bottom right table. I would like to create a button component that will add (or subtract) the value I enter into this numeric component from the value in the left table as I click. Hopefully this clarifies a bit of what I'm trying to do. The table I would like to see after is the value 99 added by the value 100. (I have two buttons for add and subtacted)

Thank you for replying franklepkowski,
I thought about that too however, I would like the button to basically execute the mathematical operation. So when I clicked the add button, it would add the values from one table to the other. I tried writing a query code for this but I couldn't get it to work.

It's still not clear what you really want. If both of these are being stored in a database table, you can select them both at the same time and add or subtract them at the same time. I'm not sure if this is what you are looking for:

  t1.value AS t1_value,
  t2.value AS t2_value,
  (t1.value + t2.value) added,
  (t1.value - t2.value) subtracted
FROM table1 t1
JOIN table2 t2
  ON =;

Click here to see the example in action.