简体   繁体   中英

Sql to mysql query convert

I write a query but its not give right result in php mysql

CREATE TABLE score
    (`id` int, `member` varchar(3), `score` int)
;

INSERT INTO score
    (`id`, `member`, `score`)
VALUES
    (1, 'abc', 1),
    (2, 'def', 5 ),
    (3, 'ghi', 100),
    (4, 'jkl', 3)
;

SELECT    @rankNo:=@rankNo+1 RankNo,
          a.*
FROM      score a, (SELECT @rankNo:=0) r 
ORDER BY `score` DESC

its work in sql but not work correctly in mysql

You're probably running multiple queries at once which you cannot do unless you use functionality that specifically supports it (ie mysqli_multi_query() ) which you almost certainly are not.

You need to run those queries separately for it to work with mysql_* functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM