语句是:
SELECT
表1字段1,
表2字段2
FROM
表1
INNER
JOIN
表2
ON
表1字段1
=
表2字段1
1、创建测试表;
create table company(companyId number, companyName varchar2(20), contacts varchar2(20));
create table users(userId number, companyId number, userName varchar2(20), userAge number, address varchar2(20));
2、插入测试数据;
insert into company values (1,'腾讯科技','马化腾');
insert into company values (2,'微软公司','鲍威尔');
insert into company values (3,'新浪科技','小明' );
insert into users values (1,1,'jack',23 , '上海');
insert into users values (2,1,'jack2', 23, '上海');
insert into users values (3,2,'jack3', 23, '上海');
insert into users values (4,2,'jack4', 23, '上海');
insert into users values (5,3,'jack5', 23, '上海');
insert into users values (6,3,'jack6', 23, '上海');
3、查询表中数据;
select from users;
4、编写sql,关联两张表;select from users t , company b where tcompanyid = bcompanyid and tcompanyid = 1;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)