• 输出存入的信息
    • (c) 2019 Microsoft Corporation。保留所有权利。
    • C:\Users\虚无>mysql -u root -p
    • Enter password: **
    • Welcome to the MySQL monitor. Commands end with ; or \g.
    • Your MySQL connection id is 18
    • Server version: 5.7.26 MySQL Community Server (GPL)
    • Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    • Oracle is a registered trademark of Oracle Corporation and/or its
    • affiliates. Other names may be trademarks of their respective
    • owners.
    • Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
    • mysql> use gsj//打开数据库
    • Database changed
    • mysql> select from student;//意为选中student这个表格,意为显示全部
    • +———+—————-+
    • | id | name |
    • +———+—————-+
    • | 1 | 郭士加 |
    • | 2 | 乐余 |
    • +———+—————-+
    • 2 rows in set (0.00 sec)


      mysql> select name,id from student1;//name,id意为显示这一列
      +—————-+———+
      | name | id |
      +—————-+———+
      | 汪科 | 1 |
      | 郭士加 | 2 |
      | 郭士加 | 2 |
      | 付宇 | 3 |
      +—————-+———+
      mysql> select from student1 where id=2;//和 where id=2,意为显示id=2,的这一行信息
      +———+—————-+———+———+
      | id | name | age | sex |
      +———+—————-+———+———+
      | 2 | 郭士加 | 20 | 男 |
      +———+—————-+———+———+

      2 rows in set (0.00 sec)
      mysql> select name from student1 where id=2;
      ERROR 2006 (HY000): MySQL server has gone away//这是在知道id=2,想输出这行中的名字
      No connection. Trying to reconnect…
      Connection id: 36
      Current database: guo
      +—————-+
      | name |
      +—————-+
      | 郭士加 |
      +—————-+
      2 rows in set (0.00 sec)

    • 模糊查询(查找包含某字符的所有信息)

    mysql> select from student where name like(‘%张%’);
    ‘’%’’可以匹配一个或多个字符,’’_’’只能匹配一个字符。
    +——+————+—————-+———+————+————+————-+————+
    | id | 学号 | name | age | 性别 | 身高 | results | 描述 |
    +——+————+—————-+———+————+————+————-+————+
    | 6 | 6 | 张国栋 | 20 | 男 | 178 | 87.00 | 无 |
    | 7 | 10 | 张家兴 | 19 | 男 | 168 | 67.00 | 无 |
    +——+————+—————-+———+————+————+————-+————+
    2 rows in set (0.00 sec)
    Limit 对查询条件进行限制,
    限制从第几条开始查,查几条·
    mysql> select
    from student order by results desc limit 1 ,3;
    按照results降序后从第2条开始查,查3条。(第一条是0)
    计算某列并显示
    mysql> select ,(results 0.9)as ‘90%’ from student;
    代表的90%那一行是显示‘results’*0.9后的值,()中可以进行任意操作