200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > sql与mysql中2个表数据进行匹配_SQL语言中把数据库中两张表数据关联起来的语句...

sql与mysql中2个表数据进行匹配_SQL语言中把数据库中两张表数据关联起来的语句...

时间:2022-04-04 06:45:31

相关推荐

sql与mysql中2个表数据进行匹配_SQL语言中把数据库中两张表数据关联起来的语句...

展开全部

1、创建32313133353236313431303231363533e59b9ee7ad9431333431373864两张测试表,

create table test_cj(name VARCHAR(20), remark varchar2(20));

create table test_kc(name VARCHAR(20), remark varchar2(20));

2、插入测试数据

insert into test_cj values('xh','cj_1');

insert into test_cj values('kcdh','cj_2');

insert into test_cj values('cj','cj_3');

insert into test_kc values('kcdh','kc_1');

insert into test_kc values('kcm','kc_2');

3、查询两张表的总记录数,select t.*, rowid from test_cj t union all select t.*, rowid from test_kc t,

4、编写sql,两张表进行关联,select t.name, t.remark, b.remark from test_cj t, test_kc b where t.name=b.name,可以发现关联出kcdh的记录,

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。