I was running this query against sakila database on MySQL 8.0.17
:
select * from film _1 where (
exists (
select * from film_actor where (
select * from (
select film_id=_1.film_id and actor_id=1
) _2
)
)
);
This gives 0
results. But if I run this:
select * from film _1 where (
exists (
select * from film_actor where (
select film_id=_1.film_id and actor_id=1
)
)
);
I got 19
results, which is expected.
Basically I wrapped the where
condition with select * from
and suddenly got the wrong result.
To my understanding, wrapping any table value with select * from
should give identical result.
I've created this fiddle.
This is confirmed to be a bug in MySQL. See https://bugs.mysql.com/bug.php?id=97461.