Click here to Skip to main content
15,886,664 members

Multilevel Marketing Website issue

sumit kausalye asked:

Open original thread
how can get extreme right and extreme left child values in store procedure for 2nd,3rd
and above layers???

suppose A is Head

and B and C are Childs of A

now if B have there childs called D and E

And C have there childs called F and G

then for 2nd Layer A will consider D as his Left And G as his right so how can i get D and G values or count to increment A...

i have made the store procedure what changes shall i made in that..

here is my store procedure

SQL
ALTER PROCEDURE [dbo].[sp_PairMatch]
	(      
		  
		   @sponcorid varchar(50)= NULL,
		   @count_mem varchar(50)= NULL,
			@regCode varchar(50)=NULL	  
     )
AS
BEGIN

	
	
	--Pair Matching
SET @count_mem=0

WHILE(@sponcorid is not null)
	BEGIN
		SET @count_mem = (select Count(*) from Registration_Master where sponcorid=@sponcorid)
		IF(@count_mem=1)
		BEGIN
			return
		END
		
		IF(@count_mem = 2)
		BEGIN
			DECLARE @persent_Count int
			SET @persent_Count = (Select count_mem from Registration_Master where regCode=@sponcorid)
   			SET @persent_Count=@persent_Count+1
			UPDATE Registration_Master SET count_mem=@persent_Count where regCode=@sponcorid

			DECLARE @temp varchar(50)
			SET @temp=@sponcorid
			set @sponcorid = (SELECT sponcorid from Registration_Master WHERE regCode=@temp )
			
--			IF((@count_mem >=20) AND (@count_mem<40))
--			BEGIN
--				UPDATE Registration_Master SET @member_status='MANAGER' where sponcorid=@sponcorid   
--			END
		END

END

END

SELECT * FROM Registration_Master WHERE regCode=@regCode


{´[edit]code block added[/edit]
Tags: SQL Server

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900