Kahuki Webmaster Forum  

Go Back   Kahuki Webmaster Forum > Website Development & Management > Programming > PHP

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-31-2008, 06:40 AM
nadyshaikh's Avatar
Rookie
 
Join Date: May 2008
Posts: 1
nadyshaikh is on a distinguished road
Question hhhhhheeeeeelp me out

i want to convert mssql query in mysql format


create table #tbl
(
userid INT,
sponsorid INT,
position varchar(10),
IsUpdated INT ,
IsSelected INT
)as set nocount ON


declare LeftCount INT
declare RightCount INT

insert into #tbl
select userid,sponsorid,position,null,null
from table1
where sponsorid = 1



while ((select count(1) from #tbl where IsUpdated is null)>1)
begin
update #tbl set IsSelected=1

insert into #tbl
select table1.userid,table1.sponsorid,#tbl.position,null, null
from table1
inner join #tbl
on #tbl.userid = table1.sponsorid
where #tbl.IsUpdated is null

update #tbl set IsUpdated = 1 where IsSelected=1
end

set @LeftCount = (select count(userid) from #tbl where position = 'Left')

set @RightCount = (select count(userid) from #tbl where position = 'Right')

select @LeftCount as lcount,@RightCount as rcount,(@LeftCount) * 250 as leftS ,(@RightCount) * 250 as RightS
select * from #tbl
drop table #tbl

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:41 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0