MySQL: SUBQUERIES

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2022
  • #MySQL #tutorial #course
    SELECT first_name, last_name, hourly_pay,
    (SELECT AVG(hourly_pay) FROM employees) AS avg_pay
    FROM employees;
    SELECT first_name, last_name
    FROM customers
    WHERE customer_id IN (SELECT DISTINCT customer_id
    FROM transactions WHERE customer_id IS NOT NULL);

ความคิดเห็น • 65

  • @BroCodez
    @BroCodez  ปีที่แล้ว +19

    SELECT first_name, last_name, hourly_pay,
    (SELECT AVG(hourly_pay) FROM employees) AS avg_pay
    FROM employees;
    SELECT first_name, last_name
    FROM employees
    WHERE hourly_pay > (SELECT AVG(hourly_pay) FROM employees);
    SELECT first_name, last_name
    FROM customers
    WHERE customer_id IN (SELECT DISTINCT customer_id
    FROM transactions WHERE customer_id IS NOT NULL);
    SELECT first_name, last_name
    FROM customers
    WHERE customer_id NOT IN (SELECT DISTINCT customer_id
    FROM transactions WHERE customer_id IS NOT NULL);

    • @sairams1928
      @sairams1928 ปีที่แล้ว

      Good job bro waiting for this playlist from you I am a big fan of your work

    • @sairams1928
      @sairams1928 ปีที่แล้ว +1

      Don't quit this playlist bro because I need to learn MySQL from a good instructor like you

    • @sairams1928
      @sairams1928 ปีที่แล้ว

      Make a playlist that will help to learn everything about SQL bro. It will definitely useful for me and also lots and lots of your subscribers so please continue don't quit this and make everyone as a master in mysql those who are all learning these videos. Thanks for your efforts 🙂

  • @adriatic123
    @adriatic123 ปีที่แล้ว +35

    After so many wrong and complicated examples on this topic finally a good and clear explanation, it helped me thanks.

  • @faidex7340
    @faidex7340 5 หลายเดือนก่อน +13

    In just a few minutes you made me understand what they explained to me at school for almost a month

  • @quantumjunction
    @quantumjunction 8 หลายเดือนก่อน +3

    Finally I've been looking for a good explanation all week and you delivered 🙌

  • @mr.nobody4159
    @mr.nobody4159 7 หลายเดือนก่อน +1

    Couldn't have explained it in a better way... appreciate it man!!!

  • @enriquepasa
    @enriquepasa ปีที่แล้ว +1

    Hi bro, thanks for the vid. Much better than most creators do. Much appreciated

  • @thatotman3942
    @thatotman3942 10 หลายเดือนก่อน +3

    your videos are so concise!!!! Niceeeee

  • @mixowentz
    @mixowentz 28 วันที่ผ่านมา

    Bro Code, from the bottom of my heart: THANK YOU.
    I'm learning sooo much from your videos, you're a life saver.

  • @mostwanted9817
    @mostwanted9817 ปีที่แล้ว +9

    Yo, I've been watching and learning from this course, soo much. I've tired learning SQL from books, but you explain it very easy.
    You are a hero, thank you BroCode!

    • @enriquepasa
      @enriquepasa ปีที่แล้ว +1

      Yeah, been in the same spot in ISTQB course too. Not quite pleasant

  • @pepijnschaap9166
    @pepijnschaap9166 ปีที่แล้ว

    thanks man u explained it really chill, not like the other ones with all weird ass terms that i dont even know

  • @pabitrakb5291
    @pabitrakb5291 ปีที่แล้ว +1

    Great explanation
    Thank you ☺️

  • @DiyAsianGuy
    @DiyAsianGuy ปีที่แล้ว +1

    Excellent tutorial!

  • @alien3.0c
    @alien3.0c ปีที่แล้ว +1

    Thanks, well explained

  • @chetanvashisth3005
    @chetanvashisth3005 5 หลายเดือนก่อน

    A very clear and concise explanation.❤❤❤

  • @yuss.0349
    @yuss.0349 หลายเดือนก่อน

    best video about this argument, ty so much

  • @Hassan-vb1hy
    @Hassan-vb1hy 11 หลายเดือนก่อน +1

    You are the bestttttttttttt❤❤❤

  • @Arzene22
    @Arzene22 4 หลายเดือนก่อน

    My professor made this more complicated than it seems. Thank you!

  • @MagnusAnand
    @MagnusAnand 8 หลายเดือนก่อน +1

    Very well explained

  • @jugmilic2096
    @jugmilic2096 3 หลายเดือนก่อน

    Thank you so much❤You explained so good❤Keep your work up❤You are insane

  • @iweijiew.2716
    @iweijiew.2716 วันที่ผ่านมา

    Thanks a lot ❤

  • @Atabanza
    @Atabanza 7 หลายเดือนก่อน

    Thank you from Colombia

  • @dawitworku821
    @dawitworku821 3 หลายเดือนก่อน

    Very helpful. Than you.

  • @pranav3579
    @pranav3579 4 หลายเดือนก่อน

    Thanks a lot really helped .

  • @Victoria-dh9jp
    @Victoria-dh9jp ปีที่แล้ว

    Great video sir 👌

  • @nockin7976
    @nockin7976 9 หลายเดือนก่อน

    Thank you from Chile

  • @basingse7934
    @basingse7934 ปีที่แล้ว

    the best, thank you

  • @TvideosTv
    @TvideosTv 3 หลายเดือนก่อน

    Thank you so much

  • @arielespindola1759
    @arielespindola1759 9 หลายเดือนก่อน

    I think you should touch on the performance too! These subqueries can be costly and suck up CPU in large tables. In the first example, the average was computed per row while $14.35 was needed only once. Other than that, great video. Thanks!

  • @bluecafe509
    @bluecafe509 ปีที่แล้ว

    Thank you.

  • @guitarguy07
    @guitarguy07 11 หลายเดือนก่อน

    love you bro

  • @catalintodoran4392
    @catalintodoran4392 4 หลายเดือนก่อน

    Thank you

  • @Siuuu-gy8ro
    @Siuuu-gy8ro ปีที่แล้ว +9

    i am also learning to use subquerry's. Tbh it's pretty damn hard, but i feel like it's one of those things you learn with much much practice

    • @XxXxnoor
      @XxXxnoor 5 หลายเดือนก่อน

      I just started learning sql 2 weeks ago and i'm really struggling with subqueries. Does it get easier with practise?

  • @AdebankeBamidele
    @AdebankeBamidele ปีที่แล้ว +2

    I finally got to understand this topic. This was amazing.
    Kudos and Bravos😂

  • @gkairdropincome
    @gkairdropincome 5 หลายเดือนก่อน

    Verey nice project

  • @googlegoogle1610
    @googlegoogle1610 ปีที่แล้ว

    bro code is a legend, but I think it is better to upload a video illustrating correlated subqueries

  • @lol-zw1mz
    @lol-zw1mz 3 หลายเดือนก่อน

    Goated

  • @sreyamathew327
    @sreyamathew327 ปีที่แล้ว

    Could you please post a detailed video for correlated subqueries?

  • @rodneyivers8677
    @rodneyivers8677 ปีที่แล้ว +3

    I have really enjoyed following your tutorials. I would like to complete some of the exercises on my own system. Are there files available to create the DB and data that you use in your videos? They would be greatly appreciated.

    • @BenjitsuID
      @BenjitsuID 7 หลายเดือนก่อน

      you can find free ones online just search it up

  • @aedrynngravitt2290
    @aedrynngravitt2290 6 หลายเดือนก่อน +1

    Do you have a template to upload into MYSQL to use your example databases to follow along and type with you?

  • @kristijanlazarev
    @kristijanlazarev 9 หลายเดือนก่อน

    godlike

  • @thubelihlentabela5735
    @thubelihlentabela5735 3 หลายเดือนก่อน

    the concat function does it have to change the table also
    becaues the query is running fine but there are no changes at the schema although i refresh it ]

  • @dhxx2905
    @dhxx2905 8 หลายเดือนก่อน

    Lmao plankton now is the employee of Krusty Krab 😂

  • @marxLz
    @marxLz ปีที่แล้ว

    This looks like a nested "if" and "loop" statements in Java. I wouldn't be learning those without your tutorials in Java. And I know I will be learning those further when I start learning the other prog. languages you have on your playlist.
    Thank you so much!

  • @fearless6141
    @fearless6141 8 หลายเดือนก่อน +1

    There are two types of subqueries?

  • @bodymohmed6493
    @bodymohmed6493 9 หลายเดือนก่อน

    🤩🤩🤩🤩🤩🤩🤩🤩🤩🤩🤩🤩🤩🤩

  • @Harrison10Miles
    @Harrison10Miles 11 หลายเดือนก่อน

    What about subqueries inside FROM?

  • @SamuelMagana-fe7up
    @SamuelMagana-fe7up ปีที่แล้ว

    Or you can use a window function

  • @xdrive300011
    @xdrive300011 10 หลายเดือนก่อน

    ok i was pretty frustrated until i started this video hearing Bro Code calling the manager as "Krabs" or craps? is this intentional? Bor Code is my type!

  • @gliecco
    @gliecco 5 หลายเดือนก่อน

    Lmao this guy should open a how to give actual good examples course

  • @MDCRITICA
    @MDCRITICA ปีที่แล้ว +1

    I'm not sure if someone could answer this but I'll try:
    SELECT first_name, last_name, hourly_pay
    FROM employees
    WHERE hourly_pay > (SELECT AVG(hourly_pay) FROM employees);
    In this query, why can't we just, after the "greater than", write "AVG(hourly_pay)" ??

    • @ScumbagLemon
      @ScumbagLemon ปีที่แล้ว

      That's what I don't get either, what's the benefit to sub-queries over shorter commands like this?

    • @omairtech6711
      @omairtech6711 10 หลายเดือนก่อน +1

      Because you have to specify the table name. There could be other tables as well and MySQL needs to know exactly which one you want the result from.

    • @fearless6141
      @fearless6141 8 หลายเดือนก่อน

      Can't we write then avg(employees.hourly_pay)

  • @damiankadziela978
    @damiankadziela978 ปีที่แล้ว +3

    The customer and transactions example would be normally done with JOIN:
    SELECT DISTINCT first_name, last_name FROM customers
    JOIN transactions ON customers.customer_id = transactions.customer_id;
    it's a bit shorter query, but it's cool to see that you can do this with other methods as well.

    • @DeeNelsonDee_nels_on_duty
      @DeeNelsonDee_nels_on_duty 6 หลายเดือนก่อน

      that's exactly what i thought so would you use an inner join for this?

  • @ojeagadaniel
    @ojeagadaniel 3 หลายเดือนก่อน +1

    I'm from the google data analytics programme and the instructor taking this part of the course is the worst ever. I didn't struggle understanding others but oh well, i have to use other resources to understand what she's saying. Very ambiguous
    Thanks anyway Bro

  • @sivuyilesifuba
    @sivuyilesifuba ปีที่แล้ว