EXIST Function in SQL

  Рет қаралды 121,849

Edredo for Learners

Edredo for Learners

Күн бұрын

Join Discussion: www.techtud.com...
IMPORTANT LINKS:
1) Official Website: www.techtud.com/
2) Virtual GATE: virtualgate.in/...
Both of the above mentioned platforms are COMPLETELY FREE, so feel free to Explore, Learn, Practice & Share!
Our Social Media Links:
Facebook Page: / techtuduniversity
Facebook Group: / virtualgate
Google+ Page: plus.google.co...
Last but not the least, SUBSCRIBE our KZbin channel to stay updated about the regularly uploaded new videos.

Пікірлер: 74
@lowkeygo
@lowkeygo 8 ай бұрын
I struggled because I did not understand the logic of how outer query recognizes the conditions in the where clause of the subquery. So this has helped me understanding the concept: 1. First look at the outer query and think it as "Each row is about to be returned!" 2. But in order for a row to be returned, "where exists" clause must be true. 3. Now we look at the where clause inside the subquery. Here, usually we make outerquery.id = subquery.id because "we are determining whether the current row should be returned or not". And this current row has its own id. Furthermore, usually, you put 1 more condition such as subquery.quantity > 2. 4. Now, the subquery will look for the id that is about to be returned in the outer query inside the subquery, and see if there's any row that meets the second condition (quantity >2). 5. If there's any row that matches the condition inside the subquery, outer query can return the current row. Otherwise, it skips and the same process repeats for the next row.
@brontesaurus1
@brontesaurus1 5 жыл бұрын
Thank you! I have struggled with this for a while. No one (teacher nor book) ever emphasized that the outer query would or would not run based on the subquery.
@luke6350
@luke6350 4 жыл бұрын
same with me. glad i found this video
@captoori
@captoori 3 жыл бұрын
Same here. Others teach like it was obvious
@KatRollo
@KatRollo 3 жыл бұрын
Difference of an effective teacher :)
@trollanddrump5326
@trollanddrump5326 4 жыл бұрын
How can you forget SEX? Unbelievable!
@sujaysshenoy247
@sujaysshenoy247 4 жыл бұрын
super clear explaination of the exists concept, i was struggling to understand this concept Thank you!!
@Avict-18
@Avict-18 3 ай бұрын
Thank you very much, I had been struggling with this for quite a while now I guess you are the one that has explained it the best> I was wondering how the outer query has recognized the condition of the inner query but now i get it
@oscarv6907
@oscarv6907 2 жыл бұрын
You explained it so well, thank you so much!
@lorraineliu8422
@lorraineliu8422 5 жыл бұрын
Very clear. Thank your for the instruction!
@amirtaghavy7647
@amirtaghavy7647 3 жыл бұрын
What is the advantage of using EXIST func in your example over setting up the query like: SELECT * FROM professor WHERE eid IN (SELECT adviser FROM student WHERE sex = 'F'); ??
@hechbkee2220
@hechbkee2220 2 жыл бұрын
Is this an alternative?
@rss1322
@rss1322 2 жыл бұрын
IN returns an array. EXIST returns a simple TRUE or FALSE. So EXIST is more efficient in this particular example. But you cannot EXIST where you need the entire array of employee ids as an output.
@gaborszepes8107
@gaborszepes8107 8 жыл бұрын
Dear Sir, I guess "EXIST" is actually "EXISTS"... I am a beginner in this field this is the reason why I am asking. Thank You for your answer in advance. Best regards, G.Sz.
@Edredo
@Edredo 8 жыл бұрын
+Gábor Szepes You are absolutely correct. The video should be improved ASAP
@vasanthavasu8696
@vasanthavasu8696 3 жыл бұрын
Use of exists function is cleared. But we can write sub queries instead of this. That will be easy to write. Then what is the purpose of using exists. Can anybody clarify on this
@angelthedecentgirl7181
@angelthedecentgirl7181 3 жыл бұрын
Thank You so much sir, i have been searching for a good video for the long time, and i finally discovered this. It is actually6 fruitful for me.
@zhijieshi692
@zhijieshi692 4 ай бұрын
will there be any value returned if only the inner query is executed? (ignore the exist, outer query)
@unnikrishnanvannadil
@unnikrishnanvannadil 3 жыл бұрын
How is this different from using IN ? In the above example wouldn't IN be a better option and take care of the same logic?
@tanishktripathi8773
@tanishktripathi8773 4 жыл бұрын
Doubts cleared at a time immense need ♥️
@stephenokon3227
@stephenokon3227 2 жыл бұрын
Thank you so much for this video. You demystified this concept in-toto! I appreciate you.
@ŁukaszSmykał
@ŁukaszSmykał 10 ай бұрын
obvious but super helpful thanks to You I bypass my problem in BigQuery :) thx:)
@r0cketRacoon
@r0cketRacoon 9 ай бұрын
is it compulsory to select ROLLNO in subquey, can I select * or any random columns ? do it have to follow any patterns of select in subquery?
@sandeepagri2218
@sandeepagri2218 3 жыл бұрын
Are you writing with mouse...!!! Coz your onscreen writing is so clear and flawless
@VanBhardwaj
@VanBhardwaj 5 жыл бұрын
Are the results produced by replacing "exists" with "not exists" in a query always mutually exclusive?
@hechbkee2220
@hechbkee2220 2 жыл бұрын
Thank you very much for your lesson..Looks easy but I do not know why I am finding it difficult
@sthk1998
@sthk1998 3 жыл бұрын
What if I want Professers with at least 2 female students? Do I do a groupby prof, count >=2 in the internal query?
@siddharthasharma9316
@siddharthasharma9316 3 жыл бұрын
he uses at least one for the EXISTS function however if such a scenario happens then we use groupby clause along with the Having Clause for conditions.
@sidharthmandal9957
@sidharthmandal9957 2 жыл бұрын
atleast 1 means:- 1 or more than 1 (i guess we need to use this in inner query using group by and having ) The video explained answer is:- find out the name of professor who has female student ! correct me if im wrong !
@shadaflorida4248
@shadaflorida4248 3 жыл бұрын
Amazing explanation! Thank you so much!
@gaydolfhitler6310
@gaydolfhitler6310 5 жыл бұрын
Thank you. excellent tutorial
@prernasemwal3016
@prernasemwal3016 3 жыл бұрын
Sir why arent we using join in the inner query as two tablesare being joined
@pradeepkumar.5172
@pradeepkumar.5172 3 жыл бұрын
thank u so much.........i understood this concept now.
@nickyevdokymov5526
@nickyevdokymov5526 Жыл бұрын
All the best coding tutorials on KZbin are made with Indian accent, lol. Thank from Ukraine, btw
@caitancorreia8379
@caitancorreia8379 8 жыл бұрын
A question sir, What would happen if instead of P.Eid =S. Advisor we just say Eid=Advisor without renaming as P and as S. What would happen then? Is that wrong?
@sukantasen1
@sukantasen1 7 жыл бұрын
It will work s well as EID and Advisor are different column name but having same datatype and you will get the same result
@pallavi4501
@pallavi4501 6 жыл бұрын
Sukanta Sen ya correct
@lordmefisto255
@lordmefisto255 5 жыл бұрын
U should use Professor.Eid=Student.Advisor because ( P is for Professor table and S is for student)
@nikolasioakimidis3003
@nikolasioakimidis3003 2 жыл бұрын
Thanks mate, that's actually a good vid
@jackdaniel1579
@jackdaniel1579 6 жыл бұрын
Can this whole Exist can be used with IN?
@Ebiru2387
@Ebiru2387 4 жыл бұрын
I have a question. A colleague wrote averysimilarly structured query, except in the subquery instead of writing "Select RollNo From....", they wrote "Select 1 From". Could one speculate this was done for efficiency? Or Could you provide your thoughts why this might be? I commonly see "Select 1" and "EXISTS" together quite frequently and am curious why it is used.
@archidar1
@archidar1 4 жыл бұрын
You only need the table after the EXISTS clause to exist (i.e. contain any value). The value itself does not matter. Hence, you can use SELECT 1 ... to save time, or show that you do not care about the value.
@lokeshphoenix
@lokeshphoenix 5 жыл бұрын
can we write select name , AVG(sal) from employee group by department having sal>AVG(sal) ??
@lordmefisto255
@lordmefisto255 5 жыл бұрын
of course ;)
@superfreiheit1
@superfreiheit1 3 жыл бұрын
Exists: IF Subquery is empty, then not execute outer-query
@mariasilverdale6444
@mariasilverdale6444 Жыл бұрын
Thank you
@Renegade_rm56
@Renegade_rm56 3 жыл бұрын
Really nice handwriting ;)
@juniorocana7171
@juniorocana7171 Жыл бұрын
Thanks!
@MarceloAgostonSchrotlin
@MarceloAgostonSchrotlin 4 жыл бұрын
THANNKSS A LOOOOOOOOOOT!!! YOU SAVE MY LIFE DUDE!!
@codestorywithMIK
@codestorywithMIK 7 жыл бұрын
very well explained
@ahmedelshenawy6357
@ahmedelshenawy6357 11 ай бұрын
Thanks..
@praveenpalina6591
@praveenpalina6591 6 жыл бұрын
Hi sir, Which one fast exists or in?why?
@yashmishra12
@yashmishra12 3 жыл бұрын
"In" is faster because the outer query is run once while in EXISTS, the outer query is run for each inner query element.
@nicofrancisco3216
@nicofrancisco3216 2 жыл бұрын
thank u very helpful
@muhammadkemalghifarirais4470
@muhammadkemalghifarirais4470 3 жыл бұрын
THANNNKS YOU ARE THE BEST!
@wordsthatcount8077
@wordsthatcount8077 Жыл бұрын
thank
@maheshmenta6078
@maheshmenta6078 5 ай бұрын
thank u
@azra8366
@azra8366 4 жыл бұрын
Thank you sir, that was helpful :)
@adaseth
@adaseth 7 жыл бұрын
#ASMR ;)
@ericzheng4815
@ericzheng4815 2 жыл бұрын
It's EXIST or EXISTS? I'm confused rn
@MiauMichigan
@MiauMichigan Жыл бұрын
With 'S'
@vaibhavmehta3424
@vaibhavmehta3424 3 жыл бұрын
okay
@p.m8042
@p.m8042 5 жыл бұрын
Are you the guy who made coding school series?
@muhammadsafiullah8428
@muhammadsafiullah8428 5 жыл бұрын
No
@hemantkilanje8865
@hemantkilanje8865 4 жыл бұрын
I didnt understand
@wajdihammami7452
@wajdihammami7452 4 жыл бұрын
fking genius
@dude789d
@dude789d 3 жыл бұрын
Atleast do your homework first...its existS not Exist...plural...
@ofek5365
@ofek5365 5 жыл бұрын
Thank you And thank god for Google Auto Generated Subtitles
@binaydhakal1731
@binaydhakal1731 3 жыл бұрын
Sexuality and Gender are not same
@tobicipher9300
@tobicipher9300 2 жыл бұрын
Gender and sex are the same, however, what we call sexuality these days are nothing more than fetishes people identify with.
@sureshk1099
@sureshk1099 2 жыл бұрын
thank you
@jordan5253
@jordan5253 4 жыл бұрын
okay
Understanding Correlated Queries in SQL
8:13
Edredo for Learners
Рет қаралды 140 М.
The SQL EXISTS clause
8:52
Database by Doug
Рет қаралды 63 М.
Teaching a Toddler Household Habits: Diaper Disposal & Potty Training #shorts
00:16
He bought this so I can drive too🥹😭 #tiktok #elsarca
00:22
Elsa Arca
Рет қаралды 53 МЛН
UNIQUE Function in SQL
7:30
Edredo for Learners
Рет қаралды 6 М.
SQL Tutorial #13 - SQL EXISTS and NOT EXISTS Operator
9:42
Software Testing Mentor
Рет қаралды 37 М.
SQL "difference between" interview questions (part 1)
8:20
Crack Concepts
Рет қаралды 617 М.
SQL | NOT IN Vs NOT EXISTS (Which one to use?)
10:03
Learn at Knowstar
Рет қаралды 11 М.
Understanding Set Comparison Operator in SQL
11:15
Edredo for Learners
Рет қаралды 35 М.
SQL Joins: Difference Between Inner/Left/Right/Outer Joins
10:52
How do indexes make databases read faster?
23:25
Arpit Bhayani
Рет қаралды 64 М.
you need to learn SQL RIGHT NOW!! (SQL Tutorial for Beginners)
24:25
NetworkChuck
Рет қаралды 1,5 МЛН
Teaching a Toddler Household Habits: Diaper Disposal & Potty Training #shorts
00:16