1
delimiter //
create procedure rankPagesLive()
BEGIN 
    SET @r=0;
    UPDATE pageslive SET Rank= @r:= (@r+1) ORDER BY fan_count DESC;
END //
delimeter ;

Error'#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter // create procedure rankPagesLive() BEGIN SET @r=0' at line 1


What's wrong?

0

3 Answers 3

2

Last line should be:

delimiter ;
Sign up to request clarification or add additional context in comments.

2 Comments

@rkcell: delimiter, not delimeter. Note the i instead of e.
oh... you're right... but the mentioned problem begin at line 1 - phpMyAdmin wasnt allowed to use delimiter )))
0

You can use a single query in a way like this

update pageslive as p
inner join (
 select @r:=@r+1 as rn,id
    from pageslive,(select @r:=0) as r order by fan_count desc
     ) as t
 on p.id = t.id
 set rank = rn

but IMHO I would avoid to store a calculated field within the table. You can always get this value with a simple select.

Comments

0

The problem was with phpmyAdmin and not with SQL code, delimiter identifier isn't allowed via SQL query (probably on my server only),

After I logged in to MySQL server by SSH - it works just fine.

Thank you for contribution.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.