Jump to content
  • 0

Inserting to another table an existing data from different table



5 answers to this question

Recommended Posts

  • 0

Hello @alexmshcare,

I am not sure that I got the Trigger goal. 

From the screenshot, I can see that the 'Staff_SpotCheck' table stores unique records that are identified by the 'SpotcheckID'.

I assume that the 'Staff_IncidentScoreBoard' table is a so-called child table, so it can store multiple records with the same SpotcheckID.

My understanding of the workflow is the following: 

1) The user updates a record in the Staff_SpotCheck' table.

2) The 'IncidentCategory' field of the updated record contains one of the listed values.

3) The 'SpotcheckID' value in the updated record does not exist in the 'SpotcheckID' field of the 'Staff_IncidentScoreBoard' table.

4) If the conditions listed above are met a new record should be inserted into the 'Staff_IncidentScoreBoard' table. Values to insert are taken from the updated record.

If this is true, you may use the LEFT JOIN  with an additional condition:


If this is not correct, please clarify the Trigger goal. 

Link to comment
Share on other sites

  • 0

I'm guessing it's something with your JOIN. I'd try removing your join altogether and putting the comparison in your WHERE section. Add an AND block outside of your OR block, and make it like "#inserted.SpotcheckID not exists SELECT SpotcheckID from StaffIncidentScoreBoard_Table". That way it would be your new comparison AND one of the 4 contains in your WHERE block.

Link to comment
Share on other sites

  • 0

Just to make sure I understand your workflow, when an update is made in the table where this triggered action contains any of the incident category values that you listed in the WHERE condition, it should insert that record in Staff_IncidentScoreBoard table if the record doesn't exist in the table yet? If yes, then I agree with @kpcollier's comment. The JOIN is the problem because it basically adds a condition that it needs to find a record in the other table that is not matching the spotcheckID of the inserted record.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...