mysql常用語句之DML語句2

2021-08-21 16:50:10 字數 460 閱讀 3306

表連線 內連線

select 列1,列2  from 表1,表2where 表1.列1= 表2.列1;

左鏈結select 列1,列2 from 表1 left join 表2 on 表1.列1 = 表2.列1;

右鏈結select 列1,列2 from 表1 right join 表2 on 表1.列1 = 表2.列1;

子查詢 in   not in     =    !=    exists      not exists

select * from 表1 where 列1 in(select 列1 from 表2);

兩個表或多個表的查詢結果 需要聯合 union    union all

select 列1 from 表1 union select 列1 from 表2;

select 列1 from 表1 union all select 列1 from 表2;【不去重】

mysql常用語句 MySQL常用語句

create table student id int primary key auto increment comment 學號 name varchar 200 comment 姓名 age int comment 年齡 comment 學生資訊 修改表注釋 alter table studen...

MySQL常用語句

and和or可以混用,and比or具有更高的優先順序,但盡量使用圓括號區分 自動過濾重複的資料owner,關鍵字distinct select distinct owner from pet 按照生日公升序排列,關鍵字order by select name,birth from pet order...

MySQL常用語句

1.insert into mis users name,age values ywm 13 select id,name,age from mis users limit 0,50 delete from mis users where id 8 update mis users set name...