How can I limit the amount of results returned?
$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
");
How can I limit the amount of results returned?
$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
");
You must be logged in to post a comment.
Like @Kaiser suggested you can specify a range (5th to 20th results, a total of 15 results are returned at max) like this:
Why not just use
get_posts()
?I always prefer function calls to raw DB queries.
As an addition to @Ashfame Answer: You can not only set a “hard” limit, but also a range, using
LIMIT 1,100
which would bring you the results 1-100.