• MySQL-SQL基础-查询2



    mysql> create table customer(mid char(5) primary key,th date,sex char(1) default '0'); Query OK, 0 rows affected (0.01 sec) mysql> desc customer; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | mid | char(5) | NO | PRI | NULL | | | name | varchar(20) | YES | | NULL | | | birth | date | YES | | NULL | | | sex | char(1) | YES | | 0 | | +-------+-------------+------+-----+---------+-------+ 4 rows in set (0.01 sec) mysql> insert into customer values('N0001','xiaoxiao','1980-11-23',1); Query OK, 1 row affected (0.00 sec) mysql> insert into customer values('N0002','bobo','1981-12-21',0); Query OK, 1 row affected (0.00 sec) mysql> create table goods(id int auto_increment primary key,name varchar(30)); Query OK, 0 rows affected (0.01 sec) mysql> insert into goods values(1,'taotao'); Query OK, 1 row affected (0.01 sec) mysql> insert into goods values(2,'meimei'); Query OK, 1 row affected (0.00 sec) mysql> select * from goods; +----+--------+ | id | name | +----+--------+ | 1 | taotao | | 2 | meimei | +----+--------+ 2 rows in set (0.00 sec) mysql> select * from customer; +-------+----------+------------+------+ | mid | name | birth | sex | +-------+----------+------------+------+ | N0001 | xiaoxiao | 1980-11-23 | 1 | | N0002 | bobo | 1981-12-21 | 0 | +-------+----------+------------+------+ 2 rows in set (0.00 sec) mysql> insert into customer values('G0001','dudu','1975-04-18',0); Query OK, 1 row affected (0.00 sec) mysql> insert into customer values('G0002','yuyu','1985-04-20',1); Query OK, 1 row affected (0.00 sec) mysql> select * from customer; +-------+----------+------------+------+ | mid | name | birth | sex | +-------+----------+------------+------+ | G0001 | dudu | 1975-04-18 | 0 | | G0002 | yuyu | 1985-04-20 | 1 | | N0001 | xiaoxiao | 1980-11-23 | 1 | | N0002 | bobo | 1981-12-21 | 0 | +-------+----------+------------+------+ 4 rows in set (0.00 sec) mysql> select * from goods; +----+--------+ | id | name | +----+--------+ | 1 | taotao | | 2 | meimei | +----+--------+ 2 rows in set (0.00 sec) mysql> select * from customer where birth=NULL; Empty set (0.00 sec) mysql> select name,birth,sex from customer where sex='1' and birth is not null; +----------+------------+------+ | name | birth | sex | +----------+------------+------+ | yuyu | 1985-04-20 | 1 | | xiaoxiao | 1980-11-23 | 1 | +----------+------------+------+ 2 rows in set (0.00 sec) mysql> select name,birth,sex from customer where birth<='1976-01-01' or birth>='1980-01-01' and sex='1'; +----------+------------+------+ | name | birth | sex | +----------+------------+------+ | dudu | 1975-04-18 | 0 | | yuyu | 1985-04-20 | 1 | | xiaoxiao | 1980-11-23 | 1 | +----------+------------+------+ 3 rows in set (0.00 sec) mysql> select name,birth,sex from customer where (birth<='1976-01-01' or birth>='1980-01-01') and sex='1'; +----------+------------+------+ | name | birth | sex | +----------+------------+------+ | yuyu | 1985-04-20 | 1 | | xiaoxiao | 1980-11-23 | 1 | +----------+------------+------+ 2 rows in set (0.01 sec) mysql> select name,birth,sex from customer order by sex asc,birth desc; +----------+------------+------+ | name | birth | sex | +----------+------------+------+ | bobo | 1981-12-21 | 0 | | dudu | 1975-04-18 | 0 | | yuyu | 1985-04-20 | 1 | | xiaoxiao | 1980-11-23 | 1 | +----------+------------+------+ 4 rows in set (0.00 sec)


  • 相关阅读:
    android app压力测试(二)——monkey测试结果分析
    android app压力测试(一)---monkey介绍及基本使用
    如何根据apk文件获取包名
    adb常用命令
    APP的安装卸载测试
    unittest生成html测试报告
    python,向已经存在数据的excel中添加数据
    HTTP协议简介
    jmeter如何确定ramp-up时间
    jmeter分布式压测
  • 原文地址:https://www.cnblogs.com/drizzle-xu/p/10256364.html
Copyright © 2020-2023  润新知