I have a table called 'individuals'. It has 5 entities i.e. ID (int,) name (String), surname (String), Age (Int) and currencyBalance(double). These are stored in a mySql Database.
I would like to make a GUI that allows the user to enter a value (as currency). This value is then added to the currencyBalance in the database.
I was thinking of making 2 SQL queries. One that returns the balance as an integer and the other updates the Balance by adding the balance returned to the user input. However how do i enter the user data in the SQL query? The idea is to have a simple working application.
I think the SQL Query queries should read something like this am i right?
SELECT balance FROM individuals WHERE ID='1'
UPDATE individuals (SELECT balance FROM individuals WHERE ID='1') SET balance=USERDATAGOESHERE WHERE name='George'
Any better refinement on the logic? Is there a better and more effective way to do this?