HomeОбразованиеRelated VideosMore From: Database by Doug

The SQL EXISTS clause

171 ratings | 22660 views
How to use the EXISTS clause in SQL. For beginners.
Html code for embedding videos on your blog
Text Comments (21)
Marshall Jackson (2 months ago)
Thank you for the explanation. Very helpful.
TheNumberEight (4 months ago)
Hi. This is great and helped me, thank you. Would you consider doing a tutorial walking through relational division? There are very few resources on the web for this and I find it very difficult to grok. Here's one of the few resources I found on it: https://www.red-gate.com/simple-talk/sql/t-sql-programming/divided-we-stand-the-sql-of-relational-division/
Database by Doug (3 months ago)
I think that's a great idea. I'll work on it and point it out to you when I post it. Thanks!
Maleki Milad (6 months ago)
Great, thanks man
Baby boB (7 months ago)
Very clear and to the point. Thanks a lot.
Thanks for your lesson that's easy to understand.
Abdul Sami (1 year ago)
can we use where exists. or where not exists with insert query ?
Database by Doug (5 months ago)
Hi Abdul. Sounds like you want to insert a record only if it doesn't exist? You can use WHERE NOT EXISTS in the SELECT that creates the records to be inserted, and you can reference the same table you are inserting into in your SELECT. You might also take a look at the MERGE statement - it might do everything you want.
Sonny (1 year ago)
Great Video. Thank you for posting.
sergeykurk (1 year ago)
i don't understand. in the first example we get ALL CategoryNames from Categories if there is at least one row in subquery ? or only CategoryNames that have products?
ntuninerlo (1 year ago)
in the first statement the subquery is true, so the query returns all records. in the second, because of the correlated subquery, only individual records correlated with each true instance are returned. at least thats what i believe to be true
ritesh sinha (1 year ago)
thanks 😃
dirtdirt (1 year ago)
Great explanation, thank you
Erlend Østlie (1 year ago)
Thanks, really helpful
Chethan Prabhu (2 years ago)
which software is that? ty
Database by Doug (2 years ago)
+Chethan Prabhu I'm using Microsoft SQL Server.
Padmini Murthy (2 years ago)
Very nicely explained
Debayan Paul (2 years ago)
It cleared my doubts. Very very helpful.
Oksana Veretiuk (3 years ago)
Thanks a lot!
Mariano Giagante (3 years ago)
Very useful and detailed. Thank you!

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.