MYSQL bug

create table tmp_demo_01 (
     id int
    ,name varchar(127)
    ,age int
)
;

create table tmp_demo_02 (
     id int
    ,name varchar(127)
)
;

insert into tmp_demo_01 
select 1 as id,'a' as name,11 as age union all
select 2 as id,'b' as name,12 as age union all
select 3 as id,'c' as name,13 as age
;

insert into tmp_demo_02
select id,name from tmp_demo_01 where id in (1,2)
;


-- tmp_demo_02并无age字段,这里用tmp_demo_01表的,正常应该是无法取到tmp_demo_01的age字段才对,不符合逻辑
select
    t1.*
from tmp_demo_01 t1
where t1.age in ( 
    select t1.age from tmp_demo_02 where id = 1
) 
;

drop table tmp_demo_01;
drop table tmp_demo_02;


posted @ 2021-12-24 10:47  chenzechao  阅读(31)  评论(0编辑  收藏  举报