UPDATE `tblclients` SET `companyname` = CONCAT(firstname, ' ', lastname) WHERE `companyname` = ''
This query calculates the current credit of the customer with id=123, making the sum of every single credit transaction
SELECT sum(amount) FROM `tblcredit` WHERE clientid=123
This query replace companyname with firstname and lastname of customer, when companyname is defined as "n/a":
UPDATE `tblclients` SET `companyname` = CONCAT(firstname, ' ', lastname) WHERE `companyname` = 'n/a'