zoukankan      html  css  js  c++  java
  • mysql之单表条件查询

    create table staff_info(
    			id int primary key auto_increment,
    			name varchar(32) not null,
    			age int(3) unsigned not null,
    			sex enum('male','female') not null default 'male',
    			duty varchar(50) not null,
    			salary decimal(15,2) not null,
    			remark varchar(100)
    ) charset=utf8;
    
    insert into staff_info(name,age,sex,duty,salary,remark) values
    ('张三',18,'male','programmer',12000.27,'我高新,我骄傲!'),
    ('zhang',88,'male','charger',80000084,'缺钱,冲我来!'),
    ('wang',24,'male','teacher',19999.990,'我可不是一朵娇花,不用怜惜我!'),
    ('刘二丫',36,'female','cooker',6000.87,null),
    ('李四五',47,'male','teacher',15550,null),
    ('echo',18,'male','teacher',20000,'走到哪里,我都要问别人:睡我不?'),
    ('翠花',17,'female','seller',7500.27,null),
    ('朵朵',23,'female','形象代言',12300.556,null);
    

    1.查看岗位是teacher的员工姓名、年龄;

    select name,age from staff_info where duty='teacher';
    

    2.查看岗位是teacher且年龄大于30岁的员工姓名、年龄;

    select name,age from staff_info where age>30 and duty='teacher';
    

    3.查看岗位是teacher且薪资在9000-1000范围内的员工姓名、年龄、薪资

    select name,age,salary from staff_info where duty='teacher' and salary between 9000 and 10000;
    

    4.查看岗位描述不为NULL的员工信息

    select * from staff_info where remark !='null';
    

    5.查看岗位是teacher且薪资是10000或9000或30000的员工姓名、年龄、薪资

    select name,age,salary from staff_info where duty='teacher' and salary in(10000,9000,30000);
    

    6.查看岗位是teacher且薪资不是10000或9000或30000的员工姓名、年龄、薪资

    select name,age,salary from staff_info where duty='teacher' and salary not in(10000,9000,30000);
    

    7.查看岗位是teacher且名字是e开头的员工姓名、年薪

    select name,salary from staff_info where name like 'e%';
    
  • 相关阅读:
    QML vs WEB
    《TO C产品经理进阶》
    《TO B产品设计标准化》
    《多元思维模型》跨学科及其核心思维模型
    产品经理审美训练
    Aria2多线程轻量级批量下载利器
    正则表达式
    如何开发一个用户脚本系列教程
    Aria2自动下载
    助贷
  • 原文地址:https://www.cnblogs.com/zhangchaocoming/p/11761597.html
Copyright © 2011-2022 走看看