samedi 30 mai 2020

recursive query to fetch user list

I have the table user which has user_name and manager name.I want to get the user who are having ramya as manager and reportee's reportee

users table

SNO user_name   manager
1    vani        Ramya
2    ramya       geetha
3    priya       ramya
4    mani        ramya
5    latha       vani
6.   hema        Anitha 
7.   kavitha     latha
8    Mala        kavitha

I want to get the name ramya and ramya's reportee vani,priya and mani and get latha who is having vani as manager who is having ramya as manager. I want to get ramya,vani,priya,mani,latha,kavitha,mala and so it if mala have any reportee. I'm trying this for laravel query

http://sqlfiddle.com/#!9/39a98e/1

select a.user_name from 
users a left join users b
on a.manager=b.user_name
where a.user_name='Ramya' or a.manager='ramya' or b.manager='Ramya'

now caught only ramya,vani,priya,mani,latha



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36JFE60
via IFTTT

Aucun commentaire:

Enregistrer un commentaire