我試圖用來自另一個表字段的輸入插入到一個字段中。雖然這是許多數據庫引擎完全可行的,從另一個表中插入值
我有以下字段,
新表模式
- 名稱
- Industryid(INT)
- Locationid(INT)
但實際記錄像,
- XXXX
- TEXT(VARCHAR)
- TEXT(VARCHAR)
不過,我想這兩個Industryid和Locationid用的ID從另一臺工業場所。
我有另外2臺用於
工業
- 編號
- 名稱
位置
- 編號
- 名稱
我的查詢,
select'insert into organizations(name,industryid,locationid)
values
('''+
Nameofthecompany+''','+
Isnull(industrytype,'Null')+','+
ISNULL(Location,'Null')+')'
from Organization`
結果
insert into organizations(name,industryid,locationid)
values
('Swamy',Telcom,Chennai)
預期結果
insert into organizations(name,industryid,locationid)
values
('Swamy',12,150)
表結構???插入查詢?請編輯你的問題。 – Freelancer 2013-04-10 05:02:43