您好我正在使用select語句將值插入到表中。但插入不會發生。 select語句的結果集中有5行。但是當我激發插入語句與選擇數據沒有被插入到表中。使用select語句在表中插入
我檢查了屬性的順序,一切似乎都是正確的。我還嘗試使用「values」關鍵字在表格中插入單行,並在此幫助下插入數據。 爲什麼我的插入不能使用「select」命令?
請幫忙。
下面是查詢
insert into schema1.tabletemp
select distinct
a.name as name,
a.stu_number as rollno,
c.userid as login_id,
b.Address as stuAddress,
b.totalgrades as FinalGrdaes
' ' as Misc
from
Schema1.stu_info a, schema1.address_info b, schema1.logindetails c
where
a.stu_no = b.record_no and
a.status in ('Active') and
c.last_name=a.stu_lname and
c.first_name=a.stu_fname and
a.stu_no not in (select distinct student_number from schema1.student_final_records);
這個查詢試圖學生數據插入到tabletemp。標準是student_final_record表中存在的學生記錄不應再次插入。因此,系統中新增的任何學號,即不存在於student_final_record中的學號都將插入到tabletemp中。
不在工作中不工作。有什麼建議麼????
請shjare您的DDL,樣本數據,並插入查詢 – ljh 2013-03-21 21:27:38
向我們展示你的SQL,也許我們可以幫助。 – 2013-03-21 21:29:09
您是否在INSERT ... SELECT之後執行了COMMIT語句? – 2013-03-22 02:35:29