I can select and join, but I can't insert with these below tables in the same time. How to insert data into joined tables?
- company(cid, comp_name)
- role(rid, role_name)
- user(uid, user_name, cid, rid)
cid,rid and uid are auto incremented primary keys.
I want to accept user_name,comp_name,role_name from the front end app and enter the user_name with corresponding cid and rid in user table. I am able to fetch the data after join from the user table but i don't know how to insert.
I have written a query:
INSERT INTO user ( user_name, cid, rid)
SELECT c.cid, r.rid FROM company c
    JOIN user u
    join role r ON c.cid = u.cid and r.rid=;
Please help. Thanks in advance
 
     
     
    