Jump to content

Recommended Posts

Hello,

 

I have this query

 

"SELECT f.file_id as file_id, f.downloads+ifnull(x.downloaders,0) as downloads ,
f.comment,f.link,f.poster,f.iamge1,f.iamge2,f.iamge3, f.read + ifnull(x.read,0) as read,
dlbytes AS dwned, format(f.finished+ifnull(x.completed,0),0) as finished, filename, url,
info, UNIX_TIMESTAMP(data) AS added, c.image, c.name AS cname, category AS catid,
uploader FROM {$TABLE_PREFIX}files as f LEFT JOIN xt_files x ON f.bin_file_id=x.file_id LEFT JOIN {$TABLE_PREFIX}categories as c ON c.id = f.category 
WHERE f.read + ifnull(x.read,0) + f.downloads+ifnull(x.downloaders,0) > 0 ORDER BY data  LIMIT  0 , 18";

 

that won't work

 

---

 

when I use 

ORDER BY data DESC LIMIT  0 , 18

it only list the last 24 hours( or 22 hours.not sure)  witch is allows under 18 posts

 

 

if I use 

ORDER BY data ASC LIMIT  0 , 18

 

it won't show anything

 

----

 

MySQL client version: 4.1.22

 

Data Field Type: datetime (2010-08-09 05:31:32)

 

How to make it list the last 18 posts not only last 24 hours

 

thank you

 

Link to comment
https://forums.phpfreaks.com/topic/210185-order-by-date-doesnt-work/
Share on other sites

thank you for the raply, will try to make my self clear

 

when i try the query with out "LIMIT" it works fine

 

ORDER BY data DESC

>>> prints 89 posts

 

my problem is when I use "LIMIT"

 

ORDER BY data DESC LIMIT  0,18

>>> prints 7 posts !! (SHOULD PRINTS 18)

ORDER BY data DESC LIMIT 0,19

>>> prints 11 posts (SHOULD PRINTS 19)

ORDER BY data DESC LIMIT 0,20

>>> prints 12 posts  (SHOULD PRINTS 20)

 

 

and number of posts will decrease over time (now it shows 11 posts after 5 hours it will be something like 7 posts)

 

And if I use "ASC" order

 

ORDER BY data ASC

>>> 0 result "no error" (SHOULD PRINTS 89 LIKE "DESC")

 

---

 

THIS PROBLEM ONLY WITH MySQL client version: 4.1.22

 

ON MY LOCALHOST with MySQL client version: 5.1.37 THE QUERY WORKS FINE WITH LIMIT

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.