lundi 23 avril 2018

fetch the recursive data in sql query using join

I have the table user which has user_name and manager name.I want to get the user name for who have manager ='test'.I want to get the user who are having ramya as manager and reportee's reportee's related project and customer

users table SNO user_name manager 1 vani Ramya 2 ramya geetha 3 priya ramya 4 mani ramya 5 latha vani 6. hema Anitha

I have the table user which has user_name and manager name.I want to get the user name for who have manager ='test'.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

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 and latha and fetch the project related to ramya,vani,priya,mani and latha from project table who are the project owner

project table
project_id    name   customer_code  owner
1              x      C1             ramya
2              xx     c2             vani
3              x1     c2             priya   
4              x2     c3             geetha
5              x3     c4             mani
6              x4     c5             latha

I want to get x,xx,x1,x3,x4 from project table.I have fetched hierarchy as

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' 

how to join project table in laravel 5.3



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

Aucun commentaire:

Enregistrer un commentaire