MySql-DQL(查询语句)

  1. 查询表中所有字段所有数据
    select * from 表名;

  2. 查询表中指定数列字段
    select 字段1,字段2,。。。 from 表名;

  3. as 字段,表名
    Select 字段1 [as] 别名1,字段2。。。 from 表名 [as] 别名

  4. Select * from 表1,表2 ;
    — 笛卡尔积连接 ,结果集是两个数据表的乘积

  5. 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

  6. 模糊查询like
    (1)% 匹配多个字符 %李_ – 倒数第二数是李
    (2)_ 匹配任意个字符 _
    SELECT * from student where name like ‘刘%’;
    SELECT * from student where name like ‘%李_%’;
    SELECT * from student where name like ‘_’;

  7. in 指定,在。。。中
    Select * from student where 字段 in (值,值。。。);
    8.Is null | is not null
    (1)Is null 没有值
    (2)Is not null 有值 包含(“”,“null”)

  8. Inner join | left join | right join | 笛卡尔积
    (1)Inner join 交集
    (2)Left join ( 交集 左表)并集
    (3)Right join (交集 右表)并集
    (4)笛卡尔积 乘积

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值