SQL JOIN: Condition in “ON” vs. “WHERE"

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ม.ค. 2025

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

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

    thank you thank you thank you so much sir i was left joinging 4 table with timestamp condition on where clause but you said in your video sometimes we have to use and instead of where and it worked thanks alot sir 😍

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  2 ปีที่แล้ว +1

      Thank you. I am delighted that you found this video helpful. Check out my other SQL videos in the series.

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

    It will be the best video for sure whoever wants clarity in where vs on. Thank you so much..great explanation step by step 🙏

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

    This is super helpful. I have been writing for SQL for 10+ years and this concept has always been one of the ones I haves struggled with. I really like this video and how you break it down. I would love to watch move videos like this or even other concepts because I like how you explain. Thanks and take care!

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

    It is a bit confusing but the step-by-step explanation helps to understand! Thank u so much.

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

    So clear! I've never thought about this!

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

    Beautifully explained! Thank you!

  • @wfvdijk1
    @wfvdijk1 2 หลายเดือนก่อน

    excellent explanation!

  • @ShoniNemavhidi
    @ShoniNemavhidi 4 ปีที่แล้ว +5

    I always thought that where clauses were evaluated first, thanks for the fine explanation.

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  4 ปีที่แล้ว +2

      Hi Shoni, Thank you for the kind words. This is a common misunderstanding. I have a video that goes into details of the sequence in which the different clauses of the SELECT statement are evaluated. See m.th-cam.com/video/xTd1T2TxfOc/w-d-xo.html Do share in your network! Thank you.

  • @Alex-hn3tx
    @Alex-hn3tx 3 ปีที่แล้ว +1

    Really well explained, excellent tutorial. Thank you

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

    Amazing Explanation. Thank you so much for your generosity.

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

    Very useful video, you explain very well! Would be happy to see more of those videos in future :)))) Wish you health and happiness!

  • @ling6701
    @ling6701 3 ปีที่แล้ว

    thanks for the whole series. This was enlightening.

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

    This is great. Thank you Sir.

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

    Very well explained thank you so much🙏

  • @lisharanka9169
    @lisharanka9169 3 ปีที่แล้ว

    Extremely helpful.

  • @abirpaul9027
    @abirpaul9027 3 ปีที่แล้ว

    This was exactly what I was looking for

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

    Excellent video and well explained, with visual examples. Thank you very much!

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

    Very well Explained

  • @TranNguyen-yi5tg
    @TranNguyen-yi5tg 3 ปีที่แล้ว

    thanks so much, i'm not confused anymore =)

  • @alanpeng1234
    @alanpeng1234 3 ปีที่แล้ว

    Thank you very much for your video.

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

    very well explained ..i always thought adding more conditions in ON clause will give precise output but i was not getting desired output ..after seeing this i understood what mistake i was making

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  4 ปีที่แล้ว

      Thank you. I'm so happy to hear that this video helped you! Be sure to also watch the other SQL videos in the collection.

  • @dontstopn0w
    @dontstopn0w 3 ปีที่แล้ว

    This was really helpful! Thank you very much

  • @yiyuanzhang9556
    @yiyuanzhang9556 3 ปีที่แล้ว

    Thank you so much! It helps a lot.

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  3 ปีที่แล้ว

      Thank you. Glad you found it useful. Check out the other videos, especially "How SQL joins work".

  • @nojoodal-ghamdi5579
    @nojoodal-ghamdi5579 5 หลายเดือนก่อน

    Amazing amazing explain

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

    One issue is that a and c both will be matched in inner join condition and than b should come accordingly please check once at 6:40 timestamp. Please confirm once

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  ปีที่แล้ว

      Sorry , but I did not understand what your question is. Are you saying there is an error in what the video shows?

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

    Awesome explanations, will you be making more videos on sql, mainly on advance sql? Or do you already have a course on other platforms?

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  2 ปีที่แล้ว

      Thank you for your kind words. Sorry, I do not have a course and do not plan on making any more SQL videos since there are many excellent ones out there already.

  • @mattsmith6828
    @mattsmith6828 3 ปีที่แล้ว

    brilliant! thank you!

  • @mzheng85
    @mzheng85 3 ปีที่แล้ว

    Thank you for the video!!! Do you have examples real world situations of when to use each one?

  • @akshay3590
    @akshay3590 4 ปีที่แล้ว

    This is the excellent tutorial sir. Just a question why did u stopped making video on SQL, please start making again

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  4 ปีที่แล้ว +1

      Hi Akshay, Thank you for the compliment. My videos are focused on concepts that are generally not so well explained by others. If there are good videos out there on a topic already, then I don't add value with yet another tutorial. Hope that makes sense.

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

    Hi sir
    How to contact you for training or guidance in databases?
    Thanks for your videos very much. Worth true gold.

  • @zackslates2128
    @zackslates2128 4 ปีที่แล้ว

    I've had this question for some time. At first, I thought not including the "on" criteria (w/ the "and" criteria) in the execution step 2 was illogical, but in thinking about it now makes sense. How can you do the "and" when the first criteria ("on" statement) isn't met. Thank you!

  • @amiteshsahu1223
    @amiteshsahu1223 4 ปีที่แล้ว

    Hello Sir, Can you please tell, which query performance is better considering the cost. Should we use the where condition before the join condition or after ?

  • @jyrrin
    @jyrrin 2 ปีที่แล้ว

    I'm a little confused. I understand the difference explained by the video, but the final query for the ON example is really no different than a LEFT JOIN without the AND keyword and it's criteria (the query output would be the same if "AND C.CustomerID IN ('A', 'B')" wasn't even written in the code).
    As stated in the video, it fails to filter the record with CustomerID = C despite only filtering for CustomerID IN ('A', 'B'). Why would someone put the filter criteria with the ON keyword instead of within a WHERE clause if putting the filter criteria with the ON keyword fails to filter in the first place (unless that was the point of the video - to show that it doesn't work).
    Thanks in advance!

    • @vigyaninctutorials-makingt6693
      @vigyaninctutorials-makingt6693  2 ปีที่แล้ว +1

      Hi Jyrrin, As you observed, the point of this video was to explain how different choices between ON vs WHERE work, so one can figure out what results to expect, or why a query is not producing the results that were intended. All of the videos in my series discuss very basic concepts, which are not well explained in other videos. For someone like you, who is further along in understanding SQL, these videos are probably too elementary, and not particularly useful. Thanks for your comment!

    • @jyrrin
      @jyrrin 2 ปีที่แล้ว

      @@vigyaninctutorials-makingt6693 Thanks for your reply! I might have been overthinking it; but believe it or not, this video was very useful!
      Respectfully,

  • @LuisAlvarez-xj5em
    @LuisAlvarez-xj5em 3 ปีที่แล้ว

    Good Job... thanks

  • @alexandrapetraberger8066
    @alexandrapetraberger8066 27 วันที่ผ่านมา

    Could someone explain, why here th-cam.com/video/f9lbm7HA7pw/w-d-xo.html outer rows for C and B are added in for where Criteria in ON? We are performing LEFT JOIN, and in the first step INNER JOIN is executed, as explained, and then OUTER JOIN is executed as the second step. Isn't it meant "remaining outer part of the LEFT JOIN" by "OUTER JOIN" ?? Because condition in ON suggests: "...AND C.CustomerID IN ('A', 'B')". In A and B! Hence, per my understanding, only CustomerID of B should be added in this step to fulfil the condition, since A is already there. Not C and B. Why the row with C is added?
    Where do I go wrong?

  • @SumanSadhukhan-md4dq
    @SumanSadhukhan-md4dq 7 หลายเดือนก่อน

    Nice

  • @sanc7753
    @sanc7753 3 ปีที่แล้ว

    Hey ..hi we are waiting for more videos...

  • @theScientificIndianK
    @theScientificIndianK 5 ปีที่แล้ว

    Excellent

  • @PandeyJii9632
    @PandeyJii9632 2 ปีที่แล้ว

    Best !!

  • @GorgeousPuree
    @GorgeousPuree 4 ปีที่แล้ว

    gold