zoukankan      html  css  js  c++  java
  • mysql 表相关操作(1)

    查询语句

    select * from t_dept
    select empno,ename,sal from t_emp  

    select
       empno,
       sal * 12 as "income"
    from t_emp

    分页

    select empno,ename from t_emp limit 10,5

      去除重复字段

      select job from t_emp      会出现重复的

    CLERK
    SALESMAN
    SALESMAN
    MANAGER
    SALESMAN
    MANAGER
    MANAGER
    ANALYST
    PRESIDENT

    select DISTINCT job from t_emp    加上关键字 DISTINCT  就不会出现重复   只能使用一个字段

    CLERK
    SALESMAN
    MANAGER
    ANALYST
    PRESIDENT

    排序  DESC 降序  ASC升序

    select empno,ename,sal,deptno from t_emp ORDER BY sal DESC

    条件查询 

    select empno,ename,sal,deptno from t_emp where deptno in (10,20) and sal >= 2000 order by deptno

    select empno,ename,sal,hiredate,deptno
    from t_emp
    where deptno = 10
    AND (sal + IFNULL(comm,0))* 12 > 15000
    AND DATEDIFF(NOW(),hiredate)/365 >= 20

    select empno,ename,sal,hiredate,deptno
    from t_emp
    where deptno in (10,20,30) and job != 'SALESMAN'

    is null  / is not null

    select empno,ename,sal,hiredate,deptno,comm
    from t_emp
    where comm is null

    BETWEEN ... AND ...

    select empno,ename,sal,hiredate,deptno,comm
    from t_emp
    where comm is null
    AND sal BETWEEN 2000 AND 3000

    LIKE  模糊查询

    select empno,ename,sal,hiredate,deptno,comm
    from t_emp
    where comm is null
    AND sal BETWEEN 2000 AND 3000
    AND ename LIKE '%A%'

  • 相关阅读:
    find 命令
    shell 脚本 测试webApp
    thinkphp模板继承
    Tp-validate进阶thinkphp
    B2B、B2C、C2C、O2O
    phpstorm自定义代码片段
    phpstorm开启xdebug断点调试,断点调试不成功来这里
    app接口设计
    socket
    字符集转换
  • 原文地址:https://www.cnblogs.com/ericblog1992/p/11315242.html
Copyright © 2011-2022 走看看