有三张表:Students表,Friends表和Salary表,请问如何找出朋友工资比自己高的人?
创建三张表的代码如下:
create table Students(
ID int NOT NULL ,
s_name char(10) NOT NULL ,
primary key(ID)
)ENGINE=InnoDB;
create table Friends(
ID int NOT NULL ,
Friend_ID int NOT NULL ,
primary key(ID)
)ENGINE=InnoDB;
create table Salary(
ID int NOT NULL ,
Salaries int NOT NULL ,
primary key(ID)
)ENGINE=InnoDB;
insert into Students(ID,
s_name)
values(1,'甲'),
(2,'乙'),
(3,'丙'),
(4,'丁');
insert into Friends(ID,
Friend_ID)
values(1,2),
(2,3),
(3,4),
(4,1);
insert into Salary(ID,
Salaries)
values(1,2000),
(2,1000),
(3,5000),
(4,500);