• MySQL where与like


    1、无条件查询语句(查询表中所有数据)

    select * from 表名

    2、查询某些列的数据(指定列)

    select 列名1,列名2,列名3 from 表名

     

     

    3、条件查询语句

    select 列名1,列名2 from 表名 where 条件

     

     

     

    举例条件,如下:

    符号

    释义

    示例

    >

    大于

    select  *  from 表名 where 列名1 > 某值

    >=

    大于等于

    select  列名1,列名2  from 表名 where 列名1 >= 某值

    <

    小于

    select  *  from 表名 where 列名1 < 某值

    <=

    小于等于

    select  列名1,列名2  from 表名 where 列名1 <= 某值

    =

    等于

    select  *  from 表名 where 列名1 = 某值

    !=

    不等于

    select  *  from 表名 where 列名1 != 某值

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    4、模糊查询:like

    a:占位符:%  指代一个或者多个字符

     

    b:占位符:_ 指代一个字符(一条语句中可以出现多次)

     

     

    例如:

    语句

    释义

    select 列名1,列名2 from 表名 where 列名1 like ‘%S’

    查询表中列名1以S结尾的数据

    select * from 表名 where 列名 like ‘s%’

    查询表中列名以S开头的数据

    select * from 表名 where 列名 like ‘%s_’

    查询表中列名倒数第二个字符是S的数据

    select * from 表名 where 列名 like ‘_s’

    查询表中列名正数第二个字符是S的数据

    select * from 表名 where 列名 like ‘_ _s’

    查询表中列名正数第三个字符是S的数据

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    LeetCode | Remove Duplicates from Sorted List
    LeetCode | Remove Duplicates from Sorted Array
    LeetCode | Merge Sorted Array
    opencv的配置、使用
    LeetCode | Merge Two Sorted Lists
    LeetCode | Minimum Depth of Binary Tree
    LeetCode | Same Tree
    LeetCode | Maximum Depth of Binary Tree
    LeetCode | Insertion Sort List
    python运算符优先级
  • 原文地址:https://www.cnblogs.com/fuxinxin/p/9711630.html
Copyright © 2020-2023  润新知