gdy do phpmyadmina wklejam takie zapytanie:
SET @rowsCount = 0; SELECT * FROM ( SELECT user_id, ( SELECT SUM( hits ) FROM pictures WHERE owner_id = user_id ) AS hits, @rowsCount := @rowsCount +1 AS rowNumber FROM users ORDER BY hits DESC ) AS tmpTable WHERE user_id = '232'
To wszystko jest ok. Jeżeli wywołam je funkcją mysql_query() otrzymuje błąd: 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 'SELECT * FROM (SELECT user_id, (SELECT SUM( hits ) FROM pictures' at line 2