1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > mysql case 嵌套子查询语句_SQL查询语句SELECT中带有case when嵌套子查询判断的问题...

mysql case 嵌套子查询语句_SQL查询语句SELECT中带有case when嵌套子查询判断的问题...

时间:2022-07-17 03:19:50

相关推荐

mysql case 嵌套子查询语句_SQL查询语句SELECT中带有case when嵌套子查询判断的问题...

展开全部

1、创建两张测试表

create table test_case1(id number, value varchar2(200));

create table test_case2(id number, value varchar2(200));

2、先在表32313133353236313431303231363533e4b893e5b19e313334313738621中插入测试数据

insert into test_case1 values(1,'a');

insert into test_case1 values(2,'b');

insert into test_case1 values(3,'c');

insert into test_case1 values(4,'d');

insert into test_case1 values(5,'e');

commit;

3、在表2中插入数据

insert into test_case2 values(1,'aa');

insert into test_case2 values(2,'bb');

insert into test_case2 values(3,'cc');

insert into test_case2 values(6,'ee');

commit;

4、两表关联,并编写case when的语句

select t.*,

case when b.id is not null then '存在' else '不存在' end flag

from TEST_CASE1 t, TEST_CASE2 b

where t.id = b.id(+)

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