I have a table: contract. Each contract has a total number of hours. When work is done within a contract, a user registers the number of hours he/she worked. This happens in the tabel: register.
I want to send a daily e-mail to management containing all contracts which are low on available hours. I use something like the following select query:
This works fine, but now I want to set a mailed field to '1' so that the same contract isn't mailed twice or more.
So I wanted an update something like this:
And now I'm stuck. :-( I've tried to use inner join and having clauses, where clauses, even if (but it gives an error because more than one records are returned). And I can't get the query to only update the records which are low on available hours.
I hope I made my problem clear, and that someone can help me out.
Thanks
I want to send a daily e-mail to management containing all contracts which are low on available hours. I use something like the following select query:
Code:
Select
(contract.hours - sum(register.registeredhours)) as available_hours
From
contract
inner join register on contract_id = register_contract_id
So I wanted an update something like this:
Code:
update
contract
set
contract_mailed = '1'
And now I'm stuck. :-( I've tried to use inner join and having clauses, where clauses, even if (but it gives an error because more than one records are returned). And I can't get the query to only update the records which are low on available hours.
I hope I made my problem clear, and that someone can help me out.
Thanks