Mysql A表 資料更新 B表

2021-09-06 08:40:44 字數 1273 閱讀 7635

1. 下面這個語句會拷貝表結構到新錶newadmin中。 (不會拷貝表中的資料)

create table newadmin like admin  

2. 下面這個語句會拷貝資料到新錶中。 注意:這個語句其實只是把select語句的結果建乙個表。所以newadmin這個表不會有主鍵,索引。

create table newadmin as   

(   

select *   

from admin   

)   3. 如果你要真正的複製乙個表。可以用下面的語句。

create table newadmin like admin;   

insert into newadmin select * from admin;  

4. 我們可以操作不同的資料庫。

create table newadmin like shop.admin;   

create table newshop.newadmin like shop.admin;  

5. 我們也可以拷貝乙個表中其中的一些字段。

create table newadmin as   

(   

select username, password from admin   

)   6. 我們也可以講新建的表的字段改名。

create table newadmin as   

(   

select id, username as uname, password as pass from admin   

)   7. 我們也可以拷貝一部分資料。

create table newadmin as   

(   

select * from admin where left(username,1) = 's'   

)   8. 我們也可以在建立表的同時定義表中的字段資訊。

create table newadmin   

(   

id integer not null auto_increment primary key   

)   

as   

(   

select * from admin   

)9、多個表的update操作 (更加 b表 修改a表資料)

update software a, t_software b set a.uninstallname = b.uninstallname where a.id =b.id

Mysql A表 資料更新 B表

1.下面這個語句會拷貝表結構到新錶newadmin中。不會拷貝表中的資料 create table newadmin like admin 2.下面這個語句會拷貝資料到新錶中。注意 這個語句其實只是把select語句的結果建乙個表。所以newadmin這個表不會有主鍵,索引。create table...

從A表更新資料到B表

update select t.report 3code as a,b.report 3code as b from branch remote run t,branch b where b.branch code t.branch code set b a 將a表中的report 3code欄位更...

mysql根據表b更新表a的資料

先將excel匯入mysql資料庫,參考 然後執行 update sean t baojia new a,test2018 b set a.supplierid b.id where a.supplier b.comname and a.isdel 0 and a.isyuanliao 原料 注意相...