I have database with a table called members, which stores data for my admin,client,technicians all in one.But now I want to break this table into three separate tables as members and techs.members table has the common fields for both all admin,client and technician. Technicians have more data than the other two.These extra data I want to store in another table called techs.In members table I have a field as ID and in techs table there is a field as tech ID.What I want is when I insert a technician data for members table that particular ID should get inserted to techs table tech ID column
1 Answer
For mysql (with auto_increment id in members table) it can be:
START TRANSACTION;
insert into members ...
insert into admin ... (id, ...) values (last_insert_id(), ...);
COMMIT;
UPDATE
After you provided structure an example is:
START TRANSACTION;
insert into members (Name, Username, Password, Level, Address, Phone)
values ('name','username','password','level','address','12345')
insert into techs (techID, price, company, comments, rate, qualification)
values (last_insert_id(), 10, 'company', 'comment', 1, 'qualification');
COMMIT;
Members.id will be created automatically because it's auto_increment field.
IDcolumn defined inmemberstable? Is itidentity(auto_increment) column?