So I had created a query which was used to calculate sales staff commission this gave me the expected result which I needed , so the next thing i needed to do was to insert these calculated values into my staff entity, at present remain NULL, but the issue was how do I place this statement to fill up the rows of the staff table, I saw many places about how to update a table column content
I just want to know how can i send the commission column to another entity’s column So from this query it lists out the commission for each and every staff member, but how can I insert all these commissions into the column of another entity like staff
Advertisement
Answer
Update the table staff
with a join to your query (without the ORDER BY
clause):
update staff s inner join ( <your query> ) t on t.staffID = s.staffID set s.columnname = t.Commission
Change columnname
to the name of the column that you want to update.
Also in your query it’s safer to GROUP BY staffID, staffName
just in case there are 2 staff members with the same name.