473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

how can i get all childs nodes from left and right of a particular parent

i have 3 tables
1. regi

in that regi fields are
Expand|Select|Wrap|Line Numbers
  1.   id - sponserid - introducerid- name- position
  2.    1-   null-      0 -           devi- o
  3.    2 -  devi-      1-           kasi-  2
  4.    3-   devi -     1-            subbu- 1 
  5.    4.   kasi  -    2-            mahi-2
  6.    5.   kasi-      2-             ram- 1
  7.    6.   subbu-     3 -           lucky-1
  8.    7.   subbu-    3-             harsha-2
2. position table
Expand|Select|Wrap|Line Numbers
  1.    pid -position
  2.    1 -  right
  3.    2 - left
  4.  
3. sponsers table

Expand|Select|Wrap|Line Numbers
  1.    cid- name
  2.    1 -  devi
  3.    2-  kasi
  4.    3- subbu
how can i get childs nodes from left and right of a particular parent.

here i used the save stored procedure in savere

Expand|Select|Wrap|Line Numbers
  1. ALTER PROCEDURE [dbo].[savere]
  2.     @sponserid varchar(50),
  3.     @introducerid int,
  4.     @placedunderid varchar(50),
  5.     @name varchar(50),
  6.     @so varchar(50),
  7.     @position int,
  8.     @gender int,
  9.     @occupation varchar(50),
  10.     @dob varchar(50),
  11.     @addr varchar(200),
  12.     @area varchar(50),
  13.     @city varchar(50),
  14.     @district varchar(50),
  15.     @state varchar(50),
  16.     @pincode varchar(50),
  17.     @email varchar(50),
  18.     @landline varchar(50),
  19.     @mobileno varchar(50),
  20.     @pwd varchar(50),
  21.     @pin varchar(50),
  22.     @nominee varchar(50),
  23.     @relation varchar(50),
  24.     @age varchar(50),
  25.     @bankpayeename varchar(50),
  26.     @accno varchar(50),
  27.     @bankname varchar(50),
  28.     @branch varchar(50),
  29.     @ifsc varchar(50)
  30.  
  31.  
  32. AS
  33. BEGIN
  34.     -- SET NOCOUNT ON added to prevent extra result sets from
  35.     -- interfering with SELECT statements.
  36.     SET NOCOUNT ON;
  37.  
  38.     -- Insert statements for procedure here
  39.     insert into re
  40.     (
  41.     sponserid ,
  42.     introducerid ,
  43.     placedunderid ,
  44.     name ,
  45.     so ,
  46.     position ,
  47.     gender ,
  48.     occupation ,
  49.     dob ,
  50.     addr ,
  51.     area ,
  52.     city ,
  53.     district ,
  54.     state ,
  55.     pincode ,
  56.     email ,
  57.     landline ,
  58.     mobileno ,
  59.     pwd ,
  60.     pin ,
  61.     nominee ,
  62.     relation ,
  63.     age ,
  64.     bankpayeename ,
  65.     accno ,
  66.     bankname ,
  67.     branch ,
  68.     ifsc,
  69.     createddate
  70.      )
  71.      values
  72.      (
  73.      @sponserid ,
  74.     @introducerid ,
  75.     @placedunderid ,
  76.     @name ,
  77.     @so ,
  78.     @position ,
  79.     @gender ,
  80.     @occupation ,
  81.     @dob ,
  82.     @addr ,
  83.     @area ,
  84.     @city ,
  85.     @district ,
  86.     @state ,
  87.     @pincode ,
  88.     @email ,
  89.     @landline ,
  90.     @mobileno ,
  91.     @pwd ,
  92.     @pin ,
  93.     @nominee ,
  94.     @relation ,
  95.     @age ,
  96.     @bankpayeename ,
  97.     @accno ,
  98.     @bankname ,
  99.     @branch ,
  100.     @ifsc ,GETDATE()
  101.     )
  102.  
  103.     declare @cid int
  104.     set @cid =SCOPE_IDENTITY()
  105.  
  106.     insert into sponsers(cid,name)values(@cid,@name)
  107. END
Nov 13 '15 #1
1 1585
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data. Second Warning.

The answer to this question is the same as the answer to your other thread about counting all the child nodes: https://bytes.com/topic/sql-server/a...tion-calculate.

You will need to write a complicated recursive query using CTE's or you will need to change the data structure to accommodate easier queries. The choice is up to you. You can get more detail about each approach in the links in your other thread.
Nov 13 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
8
by: A.M | last post by:
Hi, Using C#, what is the equivalent of functions Left, Right and Mid that we had in vb6? Thanks, Alan
11
by: Bruce A. Julseth | last post by:
I have: If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text, TextBox1.Text.Length - 1) End If Adding: Imports...
6
by: James Brown [MVP] | last post by:
Hi, I am having trouble understanding how the 'const' modifier affects the 'left-right' rule when deciphering c-declarations: const int *x; // x is a pointer to a 'const int' int const *x; ...
8
by: Chaitanya | last post by:
Hello, In my Application i want to know when user clicks both the "Left" and "Right" buttons of the Mouse. I am getting a number like this "3145728". But the MouseButtons Enum contains only Left,...
1
by: karthee | last post by:
I am creating a custom treeview with multiple selection, if i select multiple nodes and right click, the selection is disappearing, i tried with somany things like on mouse click my code is...
5
by: | last post by:
What are the equivalant to left, right, etc. in C#. How can I extract strings from a string without them? For instance, I have a string like so: ...
9
by: shapper | last post by:
Hello, I am used to SQL but I am starting to use LINQ. How can I create Left, Right and Inner joins in LINQ? How to distinguish the different joins? Here is a great SQL example:...
16
by: ImpactMan | last post by:
Need help to create an windows mobile application with a few buttons that when they are pressed/clicked they assign keys, like up, down, left, right. It is just like to create a "virtual d-pad",...
1
by: jitenrajput49 | last post by:
My tbltestingtree structure is as follow: ID ParentID IsLeft IsRight joingdate Ramesh123 NULL NULL NULL 2014-01-03...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.