This is my first post on the site. I’m a newbie with mysql and php so please pardon any mistakes and kindly point them out.
I have a table to store hiring details:
table_hiring
hiringid int(20) AUTOINCREMENT => (primary key);
hiringname varchar(80);
hiringdate bigint(20);
…
…
I have another table to store the tools and their hire prices which has:
table_tools
tool_id int(10)AUTOINCREMENT => (primary key);
tool_description varchar(100);
tool_price double;
Each hire request would be saved in the hiring table. My problem is that each hire request can have multiple tools(Its a ground hire. so the hirer can request a hurdles set, a shotput set and a javelin set and so on.). I was stumped with the problem of storing multiple values in a single field. I did some research and decided to have another table
table_tool_hire
tool_hire_id() => (primary key from table_hiring);
tool_id() => (primary key from table_tools);
tool_hire_date bigint(20);
The problem is that everytime there is a hire request, according to the hirer’s request i need to populate table_hiring and table_tool_hire in one query and the hire Id needs to be the matching in both the tables.
How do I insert the values into table_hiring and simultaneously get the autoincremented id value of that hire to be updated into the table_tool_hire table?? Please help…Thanks in advance…
For PHP, this is found with
mysql_insert_id().For .NET, take a look at this.