select exists (select 'A' where 5>10) as R;
+---+
| R |
+---+
| 0 |
+---+
Because the evaluated query return empty set, if return any value doesn't matter the value it will return 1, doesn't matter if is null or 0.
select 'A' where 5>10;
Empty set (0.00 sec)
------------------------ exists here will return 1
select exists (select NULL) as R;
+------+
| R |
+------+
| 1 |
+------+
1 row in set (0.00 sec)
-
select exists (select 0) as R;
+---+
| R |
+---+
| 1 |
+---+
select 'Ambiorix' where exists(select 1);
+----------+
| Ambiorix |
+----------+
| Ambiorix |
+----------+
No hay comentarios:
Publicar un comentario