Nested Queries | SQL | Tutorial 18

Поделиться
HTML-код
  • Опубликовано: 15 дек 2024
  • 🦒❤️ www.giraffeaca...

Комментарии • 154

  • @benweber3388
    @benweber3388 4 года назад +101

    Writing the queries separately and then combining them made the logic of nested queries much easier to understand. Nice vid!

    • @AD-do2rs
      @AD-do2rs 2 года назад +2

      Indeed .

    • @descobra5462
      @descobra5462 10 месяцев назад

      This guys way of teaching is amazing

  • @isisdominguez4776
    @isisdominguez4776 2 года назад +14

    OMG, I was struggling with Nested subqueries, but now I certainly have a better insight about it. Thank you so much and the person who shared your video in a forum.

  • @marcusg5665
    @marcusg5665 5 лет назад +28

    I feel Jim and Dwight sell more than Michael at any given time.
    Great video!

  • @DannyMontealegre22
    @DannyMontealegre22 6 лет назад +40

    Couldn’t figure out my problem.. watched this video.. then solved my problem in less than 2 mins. Thx dude!

  • @Pen_Da
    @Pen_Da 10 месяцев назад

    This made me understand the concept of nested queries better and quicker. The approach you conveyed within 5 mins is effective. Thank you so much

  • @juanfernandomoyanoramirez600
    @juanfernandomoyanoramirez600 2 года назад

    I come here from the google data analytics professional certificate and this video allowed me to understand this new concept. Thank you very much.

  • @TheMinaProject
    @TheMinaProject 2 года назад +2

    THANK YOU! BEST tutorial out there! Had no idea what was going on it class for the past 40 minutes and you sorted it in 10 😂

  • @JohnSmith-ok9sn
    @JohnSmith-ok9sn 4 года назад +1

    Mike... You are the M-A-A-AN!!!
    Thank you, so much!
    This was so clearly and simply esplained!
    On top of everything, I was working on understanding the consecutiveness of the steps machine is working in, as it evaluates the query, and I saw, (in my mind), that it worked from inside-out of the parentheses - in other words, from within the innermost parentheses' query, gradually, toward the outermost query - but, I had seen some conflicting, (to a novice, like me), explanations and examples before, and wasn't entirely clear on this.
    And YOU, Sir, did it so clearly, and eloquently!
    Thank You!

  • @beizhou1614
    @beizhou1614 2 года назад +2

    Thank you! Your explanation is so clear!

  • @tejdeepak8092
    @tejdeepak8092 2 года назад +1

    hey mike, thanks for explaining the complex topic in SQL nested query!

  • @anthonyover
    @anthonyover 4 года назад +18

    YES!!!! Thank you. This was really clear. Taking my first database class via Zoom, needing all the help I can get lol!

  • @elij8852
    @elij8852 5 лет назад +4

    Great tutorials man. I have an internship coming up in just over a week. These videos are making me feel prepped for it.

  • @lebzgold7475
    @lebzgold7475 2 года назад

    Thanks for simplifying the logic behind this!

  • @alex-sd
    @alex-sd 2 года назад +1

    Awesome explanation for nested or subqueries. Thanks so much!

  • @nesreen1978
    @nesreen1978 5 лет назад +1

    I feel I should be contributing to your channel of how beneficial it is to me, thank you, Mike!

  • @asrEthio
    @asrEthio 3 года назад +2

    Please make mor vedios on Database we need it!

  • @hildakamiza3947
    @hildakamiza3947 5 лет назад +1

    you have helped alot .. clear and understandable explaination

  • @SunshineFromWithin
    @SunshineFromWithin 2 года назад +1

    Fantastic videos, all of them. Thank you for doing this.

  • @mibo747
    @mibo747 4 года назад

    Wow.... what a clarity of explanation

  • @eishaamir5601
    @eishaamir5601 2 года назад

    Love how you used people from the Office!!!

  • @parmarrutik7845
    @parmarrutik7845 2 года назад

    nice video i want this types of more scenerio base questions solutions

  • @guitardude1007
    @guitardude1007 6 лет назад +2

    Lol love The Office examples. Great informative video

  • @TheGoldenriff
    @TheGoldenriff 5 лет назад +9

    Can we also just use an inner join?
    Select * from employee inner join works_with where total_sales > 30,000 ?

    • @lawrencew8243
      @lawrencew8243 4 года назад +1

      I'm new to this stuff and wondering the same thing..

    • @TheBorjj
      @TheBorjj 4 года назад

      Any answers?

    • @jain4613
      @jain4613 4 года назад +2

      yes it gives the same result

    • @edinelezi7691
      @edinelezi7691 4 года назад

      Any nested correlated query can be rewritten as a normal query, it says in the book Fundamentals of Database Design.

  • @mmm-bj8zg
    @mmm-bj8zg Год назад

    Taught me something my teacher couldn't, appreciate it

  • @giving1106
    @giving1106 11 месяцев назад

    Very good breakdown, thank you!

  • @okogonene9164
    @okogonene9164 2 месяца назад

    Awesome job done, how do I get all the dataset tables that was used

  • @sviatoslavslivinskiy9330
    @sviatoslavslivinskiy9330 3 года назад +1

    Such a great tutorial.
    Thanks, man!

  • @popoporiBN
    @popoporiBN 2 года назад

    believe it or not our database design lecturer did not use practical example like this and just read of what syntaxes does from textbook. holy i just understood it in a minute!

  • @shahzainahmed6851
    @shahzainahmed6851 2 года назад

    u are so good tbh , very clear

  • @elifece7847
    @elifece7847 5 лет назад +2

    can you give more questions for nested queries?

  • @sonamuhialdeen7866
    @sonamuhialdeen7866 3 года назад

    Amazing tutorial

  • @alisonlarson4882
    @alisonlarson4882 5 лет назад +6

    When is it more appropriate to use a nested query over a join? Or is it preference?

    • @djataberk1
      @djataberk1 5 лет назад

      Great question

    • @danjones9999
      @danjones9999 5 лет назад

      Anyone?

    • @linda33528
      @linda33528 5 лет назад

      literally my question and I can't find an answer either :)

    • @WarrenCromartie2
      @WarrenCromartie2 4 года назад +1

      Yes, a very good question. I would have used a table join for the first example in this tutorial, but as I'm relatively new to SQL, I assumed there was either a good reason not to, OR he was merely trying to demonstrate a principle.

  • @itsdaj
    @itsdaj 4 года назад +1

    Great video, just one problem though. You do not have Dwight in the employee table. :)

  • @rokunuzjahanrudro7571
    @rokunuzjahanrudro7571 Год назад

    Great explanation!!!

  • @bradleynguyen1429
    @bradleynguyen1429 4 года назад

    May I asked why you would not use an IN with the client branch ID in the where clause, I don’t understand why parenthesis would used in this sense. Thank you

  • @shreyansraghu6709
    @shreyansraghu6709 2 года назад +1

    Hi, I liked working on the data camp, are there any websites with a lot of tables and questions to solve more problems and practice?

  • @balrajvirdee1087
    @balrajvirdee1087 2 года назад

    Great video 👍🏽

  • @recklessvelociraptor2579
    @recklessvelociraptor2579 6 месяцев назад

    6:11 why it is called foreign key?

  • @muneebbolo
    @muneebbolo 10 месяцев назад

    Love ♥ this tutorial
    Keep it up!

  • @davidsmith6028
    @davidsmith6028 Год назад

    Awesome video, thanks so much

  • @thecritico
    @thecritico Год назад

    Subscribed!!! Great videos with C and now SQL.

  • @jethalalnhk2409
    @jethalalnhk2409 4 года назад

    very nicely explained thank you

  • @simplemente_humano
    @simplemente_humano 3 года назад

    Great video! Step by step, clear, organized! good job! Just subscribed!

  • @HiruniAbeysekara-fl1ij
    @HiruniAbeysekara-fl1ij 3 месяца назад

    Great sir❤🎉

  • @DevoutJourney
    @DevoutJourney Год назад

    Can you do this if your trying to pull from separate dbos? Or do I have to create a view with the info from each dbo I need?

  • @stevodoe4900
    @stevodoe4900 5 лет назад

    So, is it bad I didn't recognize the "re-brand" and my first thought was come on some guy stole "Mike's" video?? And, here I was going to subscribe. After a brief look at the videos, I realized my mistake and pounded that sub button. Because anyone with a hunger for computer knowledge this is a good place to start. The tutorials are simple and easy to follow for beginners and more advanced users.

  • @mashawickramasinghe195
    @mashawickramasinghe195 2 года назад

    Great video!!!👏

  • @prajwalhiremath3248
    @prajwalhiremath3248 Год назад

    8:04
    can we write 'in' instead of "="?

  • @christopherrahme780
    @christopherrahme780 5 лет назад +2

    Assuming you don't know Michael Scott's ID:
    -- Clients handled by Michael Scott's branch
    SELECT client_name FROM client WHERE branch_id IN
    (SELECT branch_id FROM branch WHERE mgr_id IN
    (SELECT emp_id FROM employee WHERE first_name = "Michael" AND last_name = "Scott"));
    -- Or you can do
    SELECT client_name FROM client WHERE branch_id IN
    (SELECT branch_id FROM branch WHERE mgr_id IN
    (SELECT emp_id FROM employee WHERE CONCAT(first_name, " ", last_name) = "Michael Scott"));

  • @safiya1363
    @safiya1363 3 года назад +1

    Can I just say a HUGE thank you as I was stuck on this one coursework question

  • @ndzalama1
    @ndzalama1 4 года назад

    Great examples, how can one play with that data (online practice

  • @sabatinosalsano743
    @sabatinosalsano743 4 года назад +2

    in these cases would be more simple just using the join statement

  • @ChicaSonidera
    @ChicaSonidera 2 года назад

    Great content, thanks.

  • @chalmerilexus2072
    @chalmerilexus2072 3 года назад +1

    You are a Star...

  • @queryhsje7514
    @queryhsje7514 Год назад

    Hi, thanks for the video! Sorry I don't get it why in the first example you were using 'IN', while in the 2nd example you were using '='? Can you explain a little detail, please? Thanks.

  • @DEEPAKS0306
    @DEEPAKS0306 4 года назад

    Being an office fanatic....i understood it better🤣👍👌

  • @lillycyriac6972
    @lillycyriac6972 5 лет назад +2

    Explanation are helpful but I do have one question.. isn't the first question to find out employees for a single client.. not sure the query address the question

    • @thesmallplateau
      @thesmallplateau 4 года назад

      I guess he means all employees who have sold +3k to one client (not a specific client). So if we have an employee who sold 1500 to a client and 1500 to another client should not be counted

  • @SRISAILAPUBRAHMAJIBCE
    @SRISAILAPUBRAHMAJIBCE Год назад

    nice explanation 😇 sir

  • @svens3722
    @svens3722 2 года назад

    i need this with calculated columns. any suggestions?

  • @jbizzy4829
    @jbizzy4829 Год назад

    This was so helpful! Thanks

  • @akj3388
    @akj3388 2 года назад

    In the very first subquery example, how would you display the client id as well along with employee's first and last name? I am happy if it repeats the name.

  • @laurenrackley4336
    @laurenrackley4336 3 года назад

    Can you do another video on a nested query but with group by? I am trying to use SQL to count adverse events for a clinical trial.

  • @cybervee_
    @cybervee_ 5 лет назад

    your explanation helps me a lot, thank you so much!

  • @GrumpySalmon
    @GrumpySalmon 3 года назад

    Can you create a video with nested queries and joins at the same time?

  • @anuradhajha9798
    @anuradhajha9798 3 года назад

    thanks, wonderful session.

  • @thrang_eo
    @thrang_eo 6 лет назад +1

    Very Well Explained Sir ♥️♥️ Thank You

  • @e3uz
    @e3uz 4 года назад +1

    If in client there was not mng_id, is that a good query for the last exercise?
    SELECT client_id, client_name
    FROM client
    WHERE client_id IN (
    SELECT client_id
    FROM works_with
    WHERE emp_id IN(
    SELECT emp_id
    FROM employee
    WHERE super_id IN (
    SELECT mgr_id
    FROM branch
    WHERE mgr_id IN (
    SELECT emp_id
    FROM employee
    WHERE employee.first_name = 'Michael' AND employee.last_name = 'Scott'
    )
    ) OR (first_name = 'Michael' AND last_name = 'Scott')
    )
    )

  • @mr.goldenball333
    @mr.goldenball333 2 года назад

    Thank you. It really helps!

  • @Jahrhcy
    @Jahrhcy 4 года назад

    Great explanation! Thank you.

  • @bradleynguyen1429
    @bradleynguyen1429 4 года назад

    Would it make a huge difference if the branch manager query was the outer query, and the client withing the nested query?

  • @WarrenCromartie2
    @WarrenCromartie2 4 года назад

    Very clearly explained. I'm just getting to grips with SQL, so forgive my ignorance! Would you use a nesting approach if you wanted to retrieve relational data for over 1000 items using Oracle where you can't input more than 1K items in a single search? Or is there a more efficient way of querying large numbers of inputs using Developer? Hope that makes sense :-)

  • @rshad4ever
    @rshad4ever 3 года назад

    omg, this is better than my professor

  • @sriramch5157
    @sriramch5157 Год назад

    We can use inner join

  • @dawitworku821
    @dawitworku821 7 месяцев назад

    Very helpful. Than you.

  • @mrinalmishra1437
    @mrinalmishra1437 2 года назад

    Just wow ❤🙏🙏🙌

  • @mohammadmayar5544
    @mohammadmayar5544 2 года назад

    Can you make video of if condition and while loop as well please

  • @NicolasSilvaVasault
    @NicolasSilvaVasault 5 лет назад

    i'm making an ecommerce website already made a db for it, but we are expanding so the nested model sounds like the best solution due to the filters and all that, but after watching this and making those huge queries (not difficult tho, just thinking about the whole mantainance and all the what would happen ifs), i feel like hierarchy model could be better, (can't work with mongodb since our hosting doesn't support it), what do you recommend me?

  • @RealityCheck6T9
    @RealityCheck6T9 4 года назад

    Thanks, good video

  • @yuneecorn
    @yuneecorn 4 года назад

    I wish I can give a million likes for this video. Thank you.

  • @alcarajo61
    @alcarajo61 3 месяца назад

    I liked the vid. You explain very well! However, isn't it a video for subqueries? I'm new to SQL but i'm under the impression you would have to go one step inner to get a nested query, right?

  • @seshurampilla4200
    @seshurampilla4200 5 лет назад

    I want to validate data from a table A and insert into another table B if value matches from A, how can we achieve it ?

  • @hardedayormoses9996
    @hardedayormoses9996 9 месяцев назад

    Pls can I have the data u work on I have your whole video on SQL but I need your pdf

  • @dimitrisapostolakis8669
    @dimitrisapostolakis8669 4 года назад

    if you dont assume you know michael scott id cant you just do it through employee table?
    for exp
    select client.client_name from client
    where client.branch_id = (
    select employee.branch_id from employee
    where first_name='Michael' and last_name='Scott'
    //you could use LIKE instead of =
    limit 1);

  • @richardmiller341
    @richardmiller341 5 лет назад

    Why is Mike in the video?

  • @ravikhatri24
    @ravikhatri24 5 лет назад

    You are the best man ,👌

  • @tucomax
    @tucomax 3 года назад

    Can't watch the video... There is an error when I try to play it.

  • @missdhara6434
    @missdhara6434 4 года назад

    I have an exam tomorrow this whole nested queries thing can get pretty complicated if you dont under stand the basics of the dos and don'ts and when to use certain functions with nested queries.

  • @leeeric6292
    @leeeric6292 2 года назад

    To make it simple, why don't use "in" in all cases?

  • @rootcause5322
    @rootcause5322 3 года назад

    This was lit 🔥 Thank u bruh...

  • @EzeChiappero
    @EzeChiappero 2 года назад

    I don't understand fully the direfence between 'IN' statement and '=' command

  • @Enkumnu
    @Enkumnu 2 года назад

    Thank you. Help a lot

  • @samcruz8188
    @samcruz8188 5 лет назад

    I’m having a difficult time finding any information on using an openquery as a subquery within an openquery. Is this possible and if so, how do I accomplish that?

  • @danielhermawan4054
    @danielhermawan4054 3 года назад +1

    I'm still confused about the difference between the 'IN' and the '=' , any explanations? thanks in advance. Great video!

    • @EzeChiappero
      @EzeChiappero 2 года назад

      Me too, same doubt

    • @danielhermawan4054
      @danielhermawan4054 2 года назад +1

      @@EzeChiappero well now I got it , the different between the equal sign (=) and the 'IN' syntax is in it's implementation. Using 'IN' means we can look for value in a range of value, for example we can use : fruit IN ("apple","pineapple","orange"), it looks better than fruit = "apple" or fruit = "pineapple" or fruit = "orange".
      Hope that helps!

    • @EzeChiappero
      @EzeChiappero 2 года назад +1

      @@danielhermawan4054 Thanks!! I'm doing exercises right now and I'm sure that this advice will make sense for me later on. Thanks a lot for the reply!

    • @EzeChiappero
      @EzeChiappero 2 года назад

      @@danielhermawan4054 In the first exercise after reading your comment I get it. Thanks, Daniel!! Great community!!

    • @danielhermawan4054
      @danielhermawan4054 2 года назад

      Cool! You learned something today haha, I hope you'll do better and better!✨🔥

  • @Merl-qi7ru
    @Merl-qi7ru Год назад

    why not just use join?

  • @protip2950
    @protip2950 4 года назад

    Why I can't play this video?

  • @ИванинаЯнчева-э6т
    @ИванинаЯнчева-э6т 5 лет назад

    Thank you for the explanation ! :D

  • @ujjawal6660
    @ujjawal6660 5 лет назад +1

    thnk u so much sir

  • @god-speed03
    @god-speed03 4 месяца назад

    Life was good when we were giraffe academy's students

  • @joelnada3483
    @joelnada3483 4 года назад

    Thank you very much bro....

  • @EzeChiappero
    @EzeChiappero 2 года назад

    Just 30 minutes ago, I upload a doubt. With the help of a mate, I got the answer right the way, great community!