goma smile Posted November 30, 2012 Report Share Posted November 30, 2012 Es zinu ka to var uztaisīt caur php bet vai caur vaicājumu nevar.......? izmantoju PDO::statement... Ideja ļoti vienkārša izvelk pēdējos 10 ORDER BY id DESC LIMIT 10.... bet man vaig lai tieši šiem pēdējiem 10 ir uzlikts Random Quote Link to comment Share on other sites More sharing options...
PheliX Posted November 30, 2012 Report Share Posted November 30, 2012 SELECT * FROM ( ... ORDER BY id DESC LIMIT 10) AS last10 ORDER BY RAND() Quote Link to comment Share on other sites More sharing options...
marcis Posted November 30, 2012 Report Share Posted November 30, 2012 PHP shuffle izpildīsies ātrāk un bez mindfuck kverijā. Iesaku atstāt kā ir - darīt to PHP pusē. Quote Link to comment Share on other sites More sharing options...
goma smile Posted December 2, 2012 Author Report Share Posted December 2, 2012 SELECT * FROM (items ORDER BY item_id DESC LIMIT 10) ORDER BY RAND() izmet erroru Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 'ORDER BY RAND()' at line 1' in C:\AppServ\www\index.php:27 Stack trace: #0 C:\AppServ\www\index.php(27): PDOStatement->execute() #1 {main} thrown in Quote Link to comment Share on other sites More sharing options...
waplet Posted December 2, 2012 Report Share Posted December 2, 2012 Un jēga, ja tu sākumā order'o pēc item id un tad šafflo? SELECT * from items ORDER by RAND() LIMIT 10 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.