Skip to content

Commit 037e9c3

Browse files
committed
understanding exists operator use in multi row sub query
1 parent 3d884c3 commit 037e9c3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use techysanoj;
2+
3+
show tables;
4+
5+
select* from ecommerce_sales_large limit 10;
6+
select max(quantity) from ecommerce_sales_large;
7+
8+
-- sub query
9+
select * from ecommerce_sales_large where quantity > 3;
10+
11+
12+
select *
13+
from ecommerce_sales_large
14+
where exists
15+
(select *
16+
from ecommerce_sales_large
17+
where quantity > 3);
18+
19+
-- exist means if the inner query returns any no of row (means simply run)
20+
-- then the outer query will work else it will not
21+
22+
23+
select *
24+
from ecommerce_sales_large
25+
where exists
26+
(select *
27+
from ecommerce_sales_large
28+
where quantity > 5); -- now this will not be having any output because inner query return 0 rows.

0 commit comments

Comments
 (0)