Insert values from another table

elarneOrefevy

New Member
I am trying to insert into a field using the input from another table field. Although this is entirely feasible for many database engine,I have the following fields,New Table Schema
  • Name
  • Industryid(int)
  • Locationid(int)
But the actual records like,
  • xxxx
  • TEXT (varchar)
  • TEXT(Varchar)
But I want these two Industryid and Locationid by id's from another table Industries, Locations. I have another 2 tables for Industries
  • Id
  • Name
Locations
  • Id
  • Name
My Query is,\[code\] select'insert into organizations(name,industryid,locationid)values('''+Nameofthecompany+''','+Isnull(industrytype,'Null')+','+ISNULL(Location,'Null')+')' from Organization`\[/code\]Result\[code\]insert into organizations(name,industryid,locationid)values('Swamy',Telcom,Chennai)\[/code\]Expected Result\[code\]insert into organizations(name,industryid,locationid)values('Swamy',12,150)\[/code\]
 
Back
Top