Subtract a field from one table from a field in second table

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
trevorm
Veteran Member
Posts: 35
Joined: 2014-07-29 08:41

Re: Subtract a field from one table from a field in second table

Post by trevorm » 2022-10-28 15:56

Hello,

There was not any error message or malfunction. The field expecting the result was empty (no zero - just blank)
Should I have this set as a calculated - I am assuming not but is set as read only

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Subtract a field from one table from a field in second table

Post by AhmedBR » 2022-10-28 16:04

It does not matter if it is read only as we are doing the update inside the database, actually better to leave it as read only.

What is the type of this field `kgs_diff` in appgini and in database?
for sure should not be calculated, as every time it updates will remove or change the value.

No error and blank field usually means wrong data type used in field.
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

trevorm
Veteran Member
Posts: 35
Joined: 2014-07-29 08:41

Re: Subtract a field from one table from a field in second table

Post by trevorm » 2022-10-28 16:10

There is no error message. The field waiting for the result is empty no zero, just blank. This is not set as a calculated field but is set read only.

I am collecting the Init_weight from the users table at runtime in the new record option and it is present in the new record option . Also the rec_weight is entered by the user at run time in the new reord option so is it necessary to call the data from the users table in the new record option.

trevorm
Veteran Member
Posts: 35
Joined: 2014-07-29 08:41

Re: Subtract a field from one table from a field in second table

Post by trevorm » 2022-10-28 16:12

Kgs_diff is read only decimal to 2 places

AhmedBR
AppGini Super Hero
AppGini Super Hero
Posts: 327
Joined: 2013-09-19 10:23

Re: Subtract a field from one table from a field in second table

Post by AhmedBR » 2022-10-28 16:15

rec_kgs and initkgs also decimal 2 places?
AppGini 22.14 - xampp 3.3.0 - PHP 7.4.30 - Summary reports - Calendar - Mass update - Messages - AppGiniHelper

trevorm
Veteran Member
Posts: 35
Joined: 2014-07-29 08:41

Re: Subtract a field from one table from a field in second table

Post by trevorm » 2022-10-28 18:50

Yes

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Subtract a field from one table from a field in second table

Post by pbottcher » 2022-10-28 19:09

Try

Code: Select all

$initkgs = sql("Select `init_kgs` from `users` where `id` = '{$data['user_id']}' ",$eo)+0;
instead of

Code: Select all

$initkgs = sqlvalue("Select `init_kgs` from `users` where `id` = '{$data['user_id']}' ",$eo)+0;
did you ever try the calculated field solution provided?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

trevorm
Veteran Member
Posts: 35
Joined: 2014-07-29 08:41

Re: Subtract a field from one table from a field in second table

Post by trevorm » 2022-10-28 19:53

Yes I did try the calculated field but I couldn’t get that to work, hence my enquiry to the forum

Post Reply