Jump to content
php.lv forumi

PDO statement query to randomize last 10 rows


Recommended Posts

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

Link to post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...