a表有3个字段:id、编码、姓名。b表有:姓名、部门、工资,用自己姓名查询工资是多小怎么写一个SQL语句?
2个回答
2015-11-24
展开全部
--创建a表
create table a(
id number,
encode varchar(30),
name varchar(20)
);
--创建b表
create table b(
name varchar(20),
deptno number,
sal number
);
--创建a表的序列
create sequence seq_a
start with 1
maxvalue 999
insert into a values(seq_a.nextval,'123','zhangsan');
insert into a values(seq_a.nextval,'123','lisi');
insert into a values(seq_a.nextval,'123','wangwu');
insert into b values('zhangsan',10,9000);
insert into b values('lisi',20,9000);
select t.* from
(select a.name,b.sal from a inner join b on a.name = b.name) t
where t.name = 'zhangsan'
望采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询