Jump to content

insert into....help please


nishmgopal

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.

Archived

This topic is now archived and is closed to further replies.

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