Question sqlite multiple tables with calculations and save back to tables

rowlandsfc

Active member
Joined
Feb 3, 2019
Messages
43
Location
bridgend
Programming Experience
Beginner
i have a database with multiple tables, i have created a sql select statement using 2 tables to make a calculation. the return works and displays the calculation correctly. what i need to do next is take the results of the calculations and save them back into the correct table. my other question is that with my query it makes the calculations for the active accounts but there is also inactive accounts that i want to display but not make the calculations for

this is where ive gotten to:
SELECT DISTINCT accid, account.custid, customer.title || ' ' || customer.firstname || ' ' || customer.lastname AS Name, product.isaname AS ProductName,product.intrate, balance, (account.accrued + ((product.intrate/365)*account.balance))AS accrued, active
FROM account
INNER JOIN customer ON customer.custid = account.custid INNER JOIN product ON product.prodid = account.prodid
WHERE active = 1
 
I'm not a SQL expert, but as I recall, SELECT and UPDATE statements have many similarities. One can rewrite a SELECT statement into UPDATE statement if the goal is to update rows instead of returning rows.[/icode]
 
Back
Top Bottom