Jump to content

Recommended Posts

Hi guys,

 

I want to insert a new record into a table, but the data is going into different tables, is this possible?

 

basically, I have a job table and this has Job Name and Job ID, then i have Skill Table, this is skill name and skill id and finally a table which brings these together, Main Table, this has the job ID, Skill ID and a particular weight for each skill.

 

The Job ID and SKill ID are automatically created.

 

what would my sql query look like if i wanted to insert:

 

a job name with skill 1, skill 2 and skill 3 and skill 1 weight=2, skill 2 weight=3 and skill 3 weight=4

 

Job name would go into Job table, Skill 1, 2 and 3 would go into skill table and then the Job ID, Skill ID and Weight would go into Main table.

 

My first thoughts are that i need more than one query

 

 

Link to comment
https://forums.phpfreaks.com/topic/152296-insert-intohelp-please/
Share on other sites

I wasnt aware of the mysql_insert_id function, so i can use this to get the last inserted ID and then insert this id into a different table?

 

Sure.

 

For example:  If you enter a Job ID into your JOB table then you can get that unique auto-incremented id with mysql_insert_id so when you go to insert into the SKILL table you can match that Job id. 

 

Hope this helps.

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.