mysql - INSERT into a table using data from 2 other tables -
okay have 3 tables; enduserdevicemap,enduser, , device.
i'm inserting enduserdevicemap need information both enduser table , device table.
insert enduserdevicemap (fkenduser,fkdevice,defaultprofile,tkuserassociation) select enduser.pkid,device.pkid enduser,device enduser.userid = 1001, device.name '%6%' values (enduser.pkid,device.pkid,'f','1')
i need device.pkid , enduser.pkid keep getting syntax error. know wrong in many ways...
first number of attributes insert should matching number of attributes of select.
second, don't need last values
line
third, sure not missing relation between tables: enduser , device, because insert possibilities.
example, (it might not make sense choice of attributes example of how use insert table):
insert enduserdevicemap (fkenduser,fkdevice,defaultprofile,tkuserassociation) select e.fkenduser,e.fkdevice,d.defaultprofile,d.tkuserassociation enduser e,device d enduser.userid = 1001 , device.name '%6%'
Comments
Post a Comment