Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Felipe Ferraz

Ajuda

Recommended Posts

Gostaria de saber se alguem pode ajudar nessa tarefa.

um amigo me passou uma query eu modifiquei oque eu sabia porem tem um problema .

 

essa query era para premiar os LOGINS da tabela z_credits memb___id mais estão premiando personagens no caso não esta buscando o memb___id e sim o nome do personagem e adicionando na tebela de créditos .

 

Img das tabela do SQL

https://i.imgur.com/apnvAWx.jpg

DECLARE @exist varchar(10)
SET @exist = 'NOT'

declare @Name varchar(10)
declare @Name2 varchar(10)
declare @Name3 varchar(10)

declare @Valor1 int
declare @Valor2 int
declare @Valor3 int

declare @Type1 int
declare @Type2 int
declare @Type3 int

SET @Valor1 = 150 --VALOR DO PRIMEIRO COLOCADO
SET @Valor2 = 100 --VALOR DO SEGUNDO COLOCADO
SET @Valor3 = 50 --VALOR DO TERCEIRO COLOCADO

SET @Type1 = 1 --TIPO DE MOEDA DO PRIMEIRO COLOCADO
SET @Type2 = 1 --TIPO DE MOEDA DO SEGUNDO COLOCADO
SET @Type3 = 1 --TIPO DE MOEDA DO TERCEIRO COLOCADO


Select top 1 @Name=Name from RankingDuelo order by Winner desc, name desc
Select top 1 @Name2=Name from RankingDuelo where Name<>@Name order by Winner desc, name desc
Select top 1 @Name3=Name from RankingDuelo where Name<>@Name and Name<>@Name2 order by Winner desc, name desc

SELECT @exist = memb___id FROM Z_Credits WHERE memb___id = @Name AND type = @Type1
if( @exist <> 'NOT' )
begin
UPDATE Z_Credits SET value = value+@Valor1 WHERE memb___id = @Name AND type = @Type1
end
else
begin
INSERT INTO Z_Credits (memb___id,value,type) VALUES (@Name,@Valor1,@Type1)
end

SET @exist = 'NOT'

SELECT @exist = memb___id FROM Z_Credits WHERE memb___id = @Name2 AND type = @Type2
if( @exist <> 'NOT' )
begin
UPDATE Z_Credits SET value = value+@Valor2 WHERE memb___id = @Name2 AND type = @Type2
end
else
begin
INSERT INTO Z_Credits (memb___id,value,type) VALUES (@Name2,@Valor2,@Type2)
end

SET @exist = 'NOT'

SELECT @exist = memb___id FROM Z_Credits WHERE memb___id = @Name3 AND type = @Type3
if( @exist <> 'NOT' )
begin
UPDATE Z_Credits SET value = value+@Valor3 WHERE memb___id = @Name3 AND type = @Type3
end
else
begin
INSERT INTO Z_Credits (memb___id,value,type) VALUES (@Name3,@Valor3,@Type3)
end
update RankingDuelo set Winner=0
update RankingDuelo set Lose=0

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.