文章目录
CREATE TABLE `employees` ( `employee_id` INT(6) NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(20) DEFAULT NULL, `last_name` VARCHAR(25) DEFAULT NULL, `email` VARCHAR(25) DEFAULT NULL, `phone_number` VARCHAR(20) DEFAULT NULL, `job_id` VARCHAR(10) DEFAULT NULL, `salary` DOUBLE(10,2) DEFAULT NULL, `commission_pct` DOUBLE(4,2) DEFAULT NULL, `manager_id` INT(6) DEFAULT NULL, `department_id` INT(4) DEFAULT NULL, `hiredate` DATETIME DEFAULT NULL, PRIMARY KEY (`employee_id`) ) ENGINE=INNODB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
concat函数 select concat(字符1,字符2,字符3,..); ifnull 函数 功能:判断 字段表达式是否为null
查询没有奖金,且工资小于20000
select * from table where commission_pct is null and salary<20000;
查询表table job 不为‘teacher’ 或者 工资为20000的员工信息
select * from table where job <>'teacher' or salary=20000; select * from table where not job = 'teacher' or salary=20000;
经典面试题
select * from table; 和 select * from table where commission_pct like '%%' and last_name like '%%'; 一样吗? 不一样 如判断的值为NULL select * from table; 和 select * from table where commission_pct like '%%' or last_name like '%%' or employee_id like '%%'; 一样吗? 一样的 总有一个值