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%';
    
  • 相关阅读:
    Spring国际化模块
    广告牌 循环 轮播 图片
    ImageLoader 网络加载图片
    ProgressBar 进度条 旋转
    UI处理 线程
    权限 动态 访问
    系统 状态栏 导航栏
    对话框 dialog 整理
    修改 字体
    获取 Activity中所有的View ViewGroup
  • 原文地址:https://www.cnblogs.com/zhangchaocoming/p/11761597.html
Copyright © 2011-2022 走看看