欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

mysql in查詢效率,利用mysql查詢每個部門工資最高的兩個人

錢衛國2年前23瀏覽0評論
mysql in查詢效率,利用mysql查詢每個部門工資最高的兩個人?

下面只定義了基本結構,其他的如索引,字符集等要酌情加上。

create table departments (

id int primary key,

name varchar(50) not null,

parent_id int

)

create table employee (

id int primary key,

department_id int not null,

name varchar(50) not null,

)

下面是一些偽代碼

department = select * from departments where name = [department_name]

departments = select * from departments where parent_id = department.id

select * from employee where department_id in [departments.id + department.id]