zoukankan      html  css  js  c++  java
  • 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的数据

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    软件设计师经验分享
    数据库设计基本规范
    UEditor上传文件的默认地址修改
    mongoDB简单介绍及安装
    链表中倒数第k个结点
    一入python深似海--对象的属性
    stl--vector 操作实现
    android5.x加入sim1,sim2标识
    leetCode 27.Remove Element (删除元素) 解题思路和方法
    java8新增特性(一)---Lambda表达式
  • 原文地址:https://www.cnblogs.com/fuxinxin/p/9711630.html
Copyright © 2011-2022 走看看