⑴ sql語句將查詢結果作為新表插入
首先創建好新表,然後
insert into new_table
select * from old_table where
⑵ sql 如何把查詢得到的結果如何放入一個新表中
表已經存在;
insert into 表名 (列名1.。。 列名n) select 列名1.。。。列名n from 表 where 條件
表不存在.
oracle
create table 新表明 as select 列名1.。。。列名n from 表 where 條件
sqlserver
select 列名1.。。。列名n
into 新表名
from 表 where 條件
⑶ sql server將查詢結果放入新表
如果只是套公式
select *into D from (
select * from A
union all
select * from B
union all
select * from C
order by ID,TM
)
⑷ mysql 資料庫 如何用sql語句查詢數據後再插入本表
你好,很高興回答你的問題。
我理解你的這個需求可以用下面的語句實現。
insert into table_a (m) select 'efg' as m from table_a where m='abc'
其他欄位自行補一下。
如果主鍵不是自增的話,還需要考慮下主鍵值。
如果有幫助到你,請點擊採納。
⑸ SqlServer中,使用sql語句實現將查詢數據結果插入一個新表中。
1、說明:復製表(只復制結構,源表名:a 新表名:b)
select * into b from a where 1<>1(僅用於SQlServer)
2、說明:拷貝表(拷貝數據,源表名:a 目標表名:b)
insert into b(a, b, c) select d,e,f from a
⑹ 在SQL中如何將多表查詢的數據插入到新的表中。
insert into E(T1,T2,T3,T4,Y1,Y2,Y3,Y4,Y5,U1,U2,U3)
select A.T1,A.T2,A.T3,B.Y1,B.Y2,B.Y3,B.Y4,B.Y5,C.U1,C.U2,C.U3 from A,B,C
where A.SuperNo=B.SuperNo and A.SuperNo=C.SuperNo;
⑺ sql 如何把查詢得到的結果如何放入一個新表中
oracle crate table 新表名 select collection_date,pub_date,count(*) as 'sum' from r_time group by pub_date,collection_date .
⑻ sql語句從一張表查詢一個欄位值插入另一個表中
標准SQL語句格式:
INSERT
INTO 表名(欄位名)
select 欄位名
from 表面
例子:將查詢出的s表中sno,j表中jno,p表中pno插入spj表中
insert
into spj(sno,jno,pno)
select sno,jno,pno
from s,j,p
(8)sql查詢結果插入新表擴展閱讀:
SQL導入語句
如果要導出數據到已經生成結構(即現存的)FOXPRO表中,可以直接用下面的SQL語句:
insert into openrowset('MSDASQL',
'Driver=Microsoft Visual FoxPro Driver;SourceType=DBF;SourceDB=c:',
'select * from [aa.DBF]')
select * from 表
說明:
SourceDB=c: 指定foxpro表所在的文件夾
aa.DBF 指定foxpro表的文件名。
⑼ SQL語句 怎麼把從一個表中查出來數據插入到另一個表中
sql語句從一張表中查詢數據插入到另一張表中的方法如下:
1、select * into destTbl from srcTbl。
2、insert into destTbl(fld1, fld2) select fld1, 5 from srcTbl。
以上兩句都是將 srcTbl 的數據插入到 destTbl,但兩句又有區別的:
第一句(select into from)要求目標表(destTbl)不存在,因為在插入時會自動創建。
第二句(insert into select from)要求目標表(destTbl)存在,由於目標表已經存在,所以我們除了插入源表(srcTbl)的欄位外,還可以插入常量。
拓展資料:
結構化查詢語言(Structured Query Language)簡稱SQL,結構化查詢語言是一種資料庫查詢和程序設計語言,用於存取數據以及查詢、更新和管理關系資料庫系統。sql 語句就是對資料庫進行操作的一種語言。
常見語句:
1、更新:update table1 set field1=value1 where 范圍。
2、查找:select * from table1 where field1 like 』%value1%』 (所有包含『value1』這個模式的字元串)。
3、排序:select * from table1 order by field1,field2 [desc]。
4、求和:select sum(field1) as sumvalue from table1。
5、平均:select avg(field1) as avgvalue from table1。
6、最大:select max(field1) as maxvalue from table1。
7、最小:select min(field1) as minvalue from table1[searator]。