-
查询表中所有字段所有数据
select * from 表名; -
查询表中指定数列字段
select 字段1,字段2,。。。 from 表名; -
as 字段,表名
Select 字段1 [as] 别名1,字段2。。。 from 表名 [as] 别名 -
Select * from 表1,表2 ;
— 笛卡尔积连接 ,结果集是两个数据表的乘积 -
DISTINCT | ALL
(1)DISTINCT 给结果集去重- 不是针对某个字段
(2)ALL 所有的结果集 (默认省略)
SELECT DISTINCT s.no
from student s ,teacher;
SELECT DISTINCT s.no
,t.name
from student s ,teacher t;
SELECT ALL s.no
,t.name
from student s ,teacher t -
模糊查询like
(1)% 匹配多个字符 %李_ – 倒数第二数是李
(2)_ 匹配任意个字符 _
SELECT * from student where name like ‘刘%’;
SELECT * from student where name like ‘%李_%’;
SELECT * from student where name like ‘_’; -
in 指定,在。。。中
Select * from student where 字段 in (值,值。。。);
8.Is null | is not null
(1)Is null 没有值
(2)Is not null 有值 包含(“”,“null”) -
Inner join | left join | right join | 笛卡尔积
(1)Inner join 交集
(2)Left join ( 交集 左表)并集
(3)Right join (交集 右表)并集
(4)笛卡尔积 乘积
MySql-DQL(查询语句)
最新推荐文章于 2022-06-21 13:52:59 发布