SQL Query To Fetch Employees Who Are Also Managers | Self Join Example | SQL Interview Question

Поделиться
HTML-код
  • Опубликовано: 1 авг 2024

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

  • @crackconcepts
    @crackconcepts  3 года назад +104

    Hi, there’s a small correction.
    The condition should be
    ON e.empid = m.man_id;

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

      Do more videos mam

    • @tanmaychoudhari7483
      @tanmaychoudhari7483 3 года назад +4

      Appreciate the efforts.
      Your videos have helped me a lot.
      But, it would be really helpful if you could edit the video or fetch in new one with the correction.
      I am sure many people are not reading comments.
      I got confused at first when you joined on emp_id on both ends.
      Thank you Sadia

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

      yupp.

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

      What will be the count of rows if we have single column in both the table

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

      Thanks Sadia, recreating the video will be more helpful as not everyone will be visiting the comment section. It may mislead them. Btw thanks a lot for all your videos. Very much helpful and easy to understand 😊

  • @ritikkaushik2469
    @ritikkaushik2469 3 года назад +16

    Can we also use inner query like
    select emp_id from employee where emp_id IN (select manager_id from employee);

  • @srinivasgollapalli5961
    @srinivasgollapalli5961 3 года назад +3

    Your videos are like quick recaps for concepts , thank you

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

    your way of teaching is amazing. explaining using query helped me to understand the purpose. i have seen videos explaining self join but this really made me understand the purpose and how to use it.

  • @UpendraYadav-te8ov
    @UpendraYadav-te8ov 3 года назад +1

    Well explained, these videos are like revision to me thank you

  • @trishjais
    @trishjais 3 года назад +9

    Joining clause is wrong , it should be e.emp_id=m.mgr_id

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

    We can use either IN or Exists as well to achieve the same

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

    u make it easy good work as always

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

    Awesome is your explanation

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

    Thanks alot for the knowledge you sharing and teaching sql concepts so simple but highly understandable. Appreciate your great effort.

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

    Hey, the contents are too good.. just one suggestion, It would be great if write queries into details part, as sometime the query and the table details are not visible.

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

    I have a question: How to display no of 'L' in each name? Like counting the char in name using SQL query

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

    Transfer the employees from department 10 to 20?
    Which syntax we can at this place

  • @riteshchaudhary9776
    @riteshchaudhary9776 3 года назад +3

    it should be e.empid=m.managerid.

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

    Please do some videos on real-time related query

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

    U r so good Sadiya Appi.....

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

    HI, I GOT A ERROR LIKE Ambiguous column name 'CITY'. CAN YOU HELP ME WITH IT?

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

    inner join should be on man_id not with empid itself

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

    Hi do you conduct sql classes.. On scenarios based plz do let m know.

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

    thanks so much!

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

    Mam could u pls say the output after that query?

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

    Who are mangers or who are also managers? I think who are mangers from the employee table

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

    I mailed you one problem statement, Can you make a video on the same.

  • @RaviKumar-lg9qp
    @RaviKumar-lg9qp 3 года назад

    I have two tables both have same records but in one table for no records inserted blank values but for another table no records, inserted null values which is okay . How can compare both tables and considering black values are equivalent to null values respectively

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

      Use ISNULL(ColumnName,'') to compare

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

    And database Ko secure kaisa rkha jay k wo crash na ho

  • @sahilbhatia2671
    @sahilbhatia2671 3 года назад +8

    Another way of doing it
    Select emp_id from employee
    Where emp_id in (select distinct man_id from employee)

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

      This will create issue where mgr_id is null

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

      @@trishjais i dont think so because we can have null values in the list but it wont effect in statement

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

      @@sahilbhatia2671 i meant if you were to find the employees who are not manager with not in statement, then it will not give you the correct result, try it yourself

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

    all videos are easy and simple to understand..good work.

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

    Super

  • @Sandeeeep.youtube
    @Sandeeeep.youtube 3 года назад +1

    Great I like your consistency in uploading video

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

    Hi.. I have a doubt.. like how to find the last employee who joined company before a given date say 10/01/21..

    • @BHARATHEEYUDU.
      @BHARATHEEYUDU. 3 года назад

      Use between operator

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

      @@BHARATHEEYUDU. that's not possible.. I don't have a interval of dates to use between.. I just want to find who was the last joinee.. there can be more thn one employees joined on same date.. I need the last one

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

      Filter record in where clause
      Where Joining Date < Given Date
      Then use order by on your identity column in desc order.
      Select Top 1 * from employee
      Where joiningdate < givendate
      Order by employeeid desc

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

      @@IQBees that sounds right 👍

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

    Good

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

    Hi madam, can you please able to provide all notes scanned pdf

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

    easiest solution found so far

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

    Miss Kiya ap notes provide kr sakti h sql k urdu m i will pay you

  • @badruddindulvi4819
    @badruddindulvi4819 5 месяцев назад

    E.EmpId=M.Man_id right ?

  • @rahulkalindi2072
    @rahulkalindi2072 Месяц назад

    select empid from employees where empid=man_id; ( without self join )

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

    Select * from employee where emp_id = man_id ?
    Is it right or not

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

      Nope..Its not correct..That will give you no result unless an employee is manager to himself..

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

      @@mohanmurali4138 we have to fetch the employee who is manager then how it is wrong

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

    How to add new column at specific position

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

      ALTER TABLE by default adds new columns at the end of the table. Use the AFTER directive to place it in a certain position within the table:

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

      Bro/sis :- consider table as employee!!!!
      If there is column place and district,in between if we need to add column “city” in between “place” and “district” use following:-
      _____________________
      alter table employee add city varchar(30) after place;
      __________________
      if we use:-
      __________________
      alter table employee add age int ;
      __________________
      Will add in last position.
      to change column name place to places
      _______________________
      alter table employee change place places varchar(30);
      _______________________
      Sorry if it’s wrong 😑

  • @AdilKhan-nl1yu
    @AdilKhan-nl1yu 3 года назад

    Your explanation is awesome

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

    I found this video in recommendation.
    I think I have found gold 💜

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

    Actually.....I am only in grade 7 so I don’t need to watch these....
    But I still viewed all your videos cause of your voice....so cute 😘😘