建表
drop table if EXISTS employee
;
create table employee
(
empId
int,
name
varchar(10),
supervisor
int,
salary
DECIMAL
);
drop table if EXISTS bonus
;
create table bonus
(
empId
int,
bonus
DECIMAL
);
insert into employee
values(1, 'John', 3, 1000);
insert into employee
values(2, 'Dan', 3, 2000);
insert into employee
values(3, 'Brad', null, 4000);
insert into employee
values(4, 'Thomas', 3, 4000);
insert into bonus
values(2, 500);
insert into bonus
values(4, 2000);
select e
.name
, b
.bonus
from employee e
left join bonus b
on e
.empId
= b
.empId
where IFNULL
(b
.bonus
,0) < 1000
转载请注明原文地址:https://blackberry.8miu.com/read-28609.html