Make nested sql query like grandfather -> father -> son details query

Completed Posted 5 years ago Paid on delivery
Completed Paid on delivery

Hello .

I have a database which have 2 columns

username and refBy

username -> its a user whose admin is refBy column

i have 3 level data

like

mdis (username) -> rajdeep (refBy)

dis (username ) -> mdis (refBy)

ret (username) -> dis (refBy)

As you can see here rajdeep is creator of mdis ,

mdis is creator of dis ,

dis is creator of ret ,

I need a query so that if i fetch rajdeep records it will give details mdis , dis and ret alongs with its creator , its like grandfather details , if i select grandfather name it will give all his son and son of son details along with father name .

I tried this query "select username,refBy from refByTmp where refBy in (SELECT username from refByTmp where refBy='rajdeep') or refBy='rajdeep'"

But its showing only 2 level data .

*Milestone will be released only after getting working query*

I have also attached sample database

Database Programming MySQL SQL

Project ID: #18990529

About the project

21 proposals Remote project Active 5 years ago

Awarded to:

frlncrsZviDAyqG

Hello Firstly although select sub queries as per your example could be used for this solution, they are extremely inefficient and on larger datasets will almost certainly overload mysql resources and/or processing t More

₹1250 INR in 1 day
(2 Reviews)
1.3

21 freelancers are bidding on average ₹1207 for this job

anshulikabansal

Hello Sir, I have understood your requirement of nested SQL statement. I can provide it to you and show you at my localhost also. Looking forward for your reply. Thanks & Regards, Anshulika Bansal

₹1100 INR in 0 days
(61 Reviews)
6.1
jayantavkumar

I am a database architect and having more than 14 years of experience in IT industry. I can help you to derive the sql query. Let me know if you want to discuss further. My Technical background • A goal-oriented More

₹1300 INR in 1 day
(28 Reviews)
4.9
PATechnology

Hi, I am interested in the task and can do it. please ping me to discuss more. thanks.

₹1500 INR in 1 day
(30 Reviews)
4.5
estebansalpeter

Hello, I've done many of these kind of 'nested' queries, or autoreferenced tables if you like. Working with families tables, as well as payroll formulas which reference one another. Please feel free to contact me, I' More

₹1500 INR in 1 day
(8 Reviews)
4.2
sreenivas2903

Hi i already have the query and need to chnges a se per ur requirement if u can able to give sample db i will do chnges and gice u the query Ping me if u r interested

₹1750 INR in 1 day
(17 Reviews)
4.5
HKaraarslan

Hello, Using nested Select is much complicated for this case. You need to use joins. I created the sample table, and get the result as you want: mdis,dis,ret But I tried this on MsSql. I think the logic must b More

₹1700 INR in 1 day
(5 Reviews)
3.8
naveenrgowdackm

I went through the requirement and It can be done using nested query I can quickly help you and release the milestone once done

₹1300 INR in 1 day
(5 Reviews)
3.1
techwrappers

Hello there, Gone through your details and after reading over your application this looks like a perfect fit for my skill sets!! I am a Database programmer with 12+ yrs of experience, I am having a good project More

₹2050 INR in 1 day
(1 Review)
2.8
kb0018896

hi i have worked on such query earlier when my project was for multi-level marketing. i can write this script. lets connect. award me the project only after the query is working.

₹1300 INR in 1 day
(4 Reviews)
1.4
ernehasingh478

I am a PHP developer working with HTML, CSS, JAVASCRIPT, PHP, Codeigniter and JQERY and laravel. My competencies include PHP, Codeigniter, APIs, HTML, CSS, JAVASCRIPT, PHP, JQERY, AJAX1 and MYSQL.

₹1300 INR in 1 day
(0 Reviews)
0.0
ratiniketan

Hi , I am new to freelancer. but having more than 6 years experience in php mysql project.I can solve your query.

₹1500 INR in 1 day
(0 Reviews)
0.0
karthikkittu9

Hi, This is karthik who works in TCS, India as SQL developer. I can complete your work in small span of time. pay be if you are satisfied with my work and friendly nature. Thanks, karthik.

₹600 INR in 1 day
(0 Reviews)
0.0
puneet1011

Just started as a freelancer. Can help you with your problem. having 2+years of experience. looking forward to discussing with you.

₹650 INR in 1 day
(0 Reviews)
0.0
tinutini

Please message me. We can discuss for fix price per package. Please review my profile. https://www.freelancer.com/u/vw7590795vw.html I have 9 years experience in MS SQL Server. Please let me know more details and w More

₹600 INR in 1 day
(0 Reviews)
0.0
karan093

Hello I have immense experience working with SQL and can get it done for you in no time. Thanks.

₹950 INR in 1 day
(0 Reviews)
0.0
EnamulHoque007

Dear Hiring Manager, I have read your problem and I'm willing to solve your problem if you give the chance. Hope you will give me the chance.

₹850 INR in 1 day
(0 Reviews)
0.0
Papuas64

Hi! I made a query for you. For the case when you have 3 levels I can not attach to the application. Get into contact with me.

₹1550 INR in 1 day
(0 Reviews)
3.0