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的数据

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    11前端css动画
    10前端css文本和字体
    09前端css3渐变
    08前端css3背景
    07前端css3边框和圆角
    06前端css3增加选择器
    堡垒机Teleport
    Sublime Text 3注册及中文乱码问题解决
    Linux部署KMS激活Windows 10和Office 2016
    服务器维护实施步骤
  • 原文地址:https://www.cnblogs.com/fuxinxin/p/9711630.html
Copyright © 2011-2022 走看看