Chepa Posted September 24, 2008 Report Share Posted September 24, 2008 ir kverijs: SET @rownum := 0; SELECT * FROM ( SELECT @rownum := @rownum+1 AS rank, user_id, points_this_month, nick, points_month FROM v_auth WHERE points_month = '92008' ORDER BY points_this_month DESC, user_id ) AS derived_table WHERE user_id = '2' LIMIT 1; no phpmyadmin jams darbojas, bet palaižot no php koda atgriež erroru: 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 @rownum := @rownum+1 AS rank, user_id, points_this_m' at line 1 wtf? Link to comment Share on other sites More sharing options...
codez Posted September 24, 2008 Report Share Posted September 24, 2008 http://lv2.php.net/manual/en/mysqli.multi-query.php Link to comment Share on other sites More sharing options...
andrisp Posted September 24, 2008 Report Share Posted September 24, 2008 (edited) Pastāv arī iespēja to visu pārnest uz procedūru. Tas tā - ja nav pieejams mysqli modulis. Un vispār - vai tik nevarēja vienkārši sadalīt to visu pa kverijiem un izpildīt atsevišķi pēc kārtas ? Man liekas, ka otrajā kverijā būs piejams pirmajā kverijā uzsetotais mainīgais. Edited September 24, 2008 by andrisp Link to comment Share on other sites More sharing options...
codez Posted September 24, 2008 Report Share Posted September 24, 2008 Vēl var @rownum inicializāciju ielikt papildus selektā SELECT * FROM ( SELECT @rownum := @rownum+1 AS rank, user_id, points_this_month, nick, points_month FROM v_auth,(SELECT @rownum:=0) as t2 WHERE points_month = '92008' ORDER BY points_this_month DESC, user_id ) AS derived_table WHERE user_id = '2' LIMIT 1 ; Link to comment Share on other sites More sharing options...
Chepa Posted September 24, 2008 Author Report Share Posted September 24, 2008 (edited) andrisp, ja biji domājis sadalīt izveidojot temporary table, tad darbojas. ty (: mysql_query("SET @rownum := 0;"); mysql_query("CREATE TEMPORARY TABLE ranking as (SELECT @rownum := @rownum+1 AS rank, user_id, points_this_month, nick, points_month FROM v_auth WHERE points_month = '$points_month' ORDER BY points_this_month DESC, user_id); "); $query3=mysql_query("SELECT * FROM ranking WHERE user_id = '2345';") or die(mysql_error()); Edited September 24, 2008 by Chepa Link to comment Share on other sites More sharing options...
Recommended Posts