Jump to content

Inserting data in multiple tables


mcmuney

Recommended Posts

What I'm trying to do involves 3 tables:

 

Table1: id, status

Table2: id, value

Table3: id, value1, value2

 

Step1: Pull all unique id numbers where status=1 from Table1

Step2: For each id pulled in Step1, insert a value=(random number between 1-5; important: the random number should be different for each insert for each id) into Table2

Step3: For each id and value inserted in Step2, update in Table3 where Table3.id=Table2.id  set value1=(existing value +1) and value2=(existing value +the random value inserted in Step2

 

Any guidance would be greatly appreciated. Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.