sql從一張表中查詢數據插入到另一張表中


比如我有兩張表

table1 字段 uname,age,address,school,

table2 字段 stuname,address.


1、我想把從table2中查詢出數據插入到table1中,而且我想插入時加入一些默認數據,改怎么寫呢,

如: insert into table1(uname,address,school) values(name 和address 從table2中查,school是一個固定值)

  insert into table1(uname,address,school) select name,address,'北京大學' from table2


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM