Subtract amounts from 2 databases

Hi there.

I have a database called mywebcha_IMincome and in there a table called amount

I also have a database called mywebcha_IMexpense and in there a table also called amount

how do i subtract the sum of one from the other ?

Also how do i display as 2 decimal places ?

For example if income amount = 500 and expense amount = 300.50 it returns a value of 199.50 ?

Thanks

First, fix your database. There should only be one database and one table.

OK i have one database inside there i have table incomeuser1 column AMOUNT and expenseuser1 column AMOUNT1

If you store income amounts as positive numbers and expense amounts as negative numbers, in one table, you can get the total using SUM(amount) in a query.

To track data for more than one account/user, have an account_id/user_id column in the single table.

Sponsor our Newsletter | Privacy Policy | Terms of Service