• 6- MySQL条件查询与通配符


    -数据库表中一般包含大量的数据,很少需要查询表中的所有行,通常只会根据特定的需要提取表中的一部分数据。这个时候需要制定查询条件,及过滤条件。

    -在select语句中,数据库根据where字句中指定的查询条件进行过滤。where字句位于表名之后。

    -格式:select列名 from 表名 where 列满足的条件;

    and操作符

    OR操作符

    注意:在使用and/or的操作符中 and操作符优先级更高。

    IN操作符

    not操作符

    LIKE操作符

    -通配符是用来匹配值的一部分的特殊字符。

    -为了在查找自剧中使用通配符,必须使用like操作符,like指示MySQL后跟的查找模式利用通配符匹配而不是直接相等匹配进行比较。

    百分号(%)通配符

    下划线通配符

    第二个字符是T的id怎么查询

    select * from products where id like ‘_T%’;

    _通配符特点:

    与%不同每个只能站位一个。

    查询: select 列 from 表

    去重: distinct

    排序:order by 方向 :asc desc

    限定返回行数:limit 你 limit n,m

    查询结果过滤:where

    操作符:between and ,and,or,in,not,is null ,is not null

    模糊查询:like操作符 通配符:%任意字符任意次数 , _一个字符。

  • 相关阅读:
    【poj1733】 Parity game
    【poj1018】 Communication System
    【poj1017】 Packets
    【poj1568】 Find the Winning Move
    【poj1085】 Triangle War
    【bzoj1082】 SCOI2005—栅栏
    【codevs1086】 栈
    【bzoj3240】 Noi2013—矩阵游戏
    【bzoj1951】 Sdoi2010—古代猪文
    中国剩余定理学习笔记
  • 原文地址:https://www.cnblogs.com/Chamberlain/p/10977061.html
Copyright © 2020-2023  润新知