zoukankan      html  css  js  c++  java
  • mysql的select查询语句

    1.简单查询

    mysql> select * from students;
    +------------+----------+------+------+
    | id         | sname    | sex  | tid  |
    +------------+----------+------+------+
    | 0000000001 | orna     | 男   | NULL |
    | 0000000002 | luscy    | 女   | NULL |
    | 0000000003 | wangwu   | 男   | NULL |
    | 0000000020 | zhangsan | 男   | NULL |
    +------------+----------+------+------+
    4 rows in set (0.00 sec)
    
    
    mysql> select id,ifnull(sname,'无') name from students;
    +------------+----------+
    | id         | name     |
    +------------+----------+
    | 0000000001 | orna     |
    | 0000000002 | luscy    |
    | 0000000003 | wangwu   |
    | 0000000020 | zhangsan |
    +------------+----------+
    4 rows in set (0.00 sec)

       mysql> select * from students where sname like 'o%';
       +------------+-------+------+------+
       | id | sname | sex | tid |
      +------------+-------+------+------+
      | 0000000001 | orna | 男 | NULL |
      +------------+-------+------+------+
      1 row in set (0.00 sec)

    2.排序

    mysql> select * from students order by sname desc;
    +------------+----------+------+------+
    | id         | sname    | sex  | tid  |
    +------------+----------+------+------+
    | 0000000020 | zhangsan | 男   | NULL |
    | 0000000003 | wangwu   | 男   | NULL |
    | 0000000001 | orna     | 男   | NULL |
    | 0000000002 | luscy    | 女   | NULL |
    +------------+----------+------+------+
    4 rows in set (0.00 sec)
    
    mysql> select * from students order by sname desc limit 1;
    +------------+----------+------+------+
    | id         | sname    | sex  | tid  |
    +------------+----------+------+------+
    | 0000000020 | zhangsan | 男   | NULL |
    +------------+----------+------+------+
    1 row in set (0.00 sec)
    

      

  • 相关阅读:
    RAC一个节点自动重启问题分析
    Oracle Audit 审计总结
    oracle 11g日志审计
    在线剪辑歌曲
    转载:MySQL Cluster NDB(Mysql 集群)
    U 盘多系统安装盘制作神器YUMI
    转载:网站限制IP地址访问-精确到国家/省/市IP地址
    开源企业云盘Seafile部署
    K8S(二)-创建一个pod应用
    mariadb升级
  • 原文地址:https://www.cnblogs.com/orna/p/8298931.html
Copyright © 2011-2022 走看看