How to get row number in this query


How to get row number in this query



I have the following WP_Query($arg):


WP_Query($arg)


$arg = array(
'post_type' => 'ma_novel',
'post_status'=>'fn_publish',
'posts_per_page' => 10,
'order' => 'DESC',
'orderby' => 'meta_value_num',
);



That does this SQL:


SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
WHERE 1=1
AND (wp_postmeta.meta_key = 'ma_rating')
AND wp_posts.post_type = 'fn_novel'
AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_postmeta.meta_value+0 DESC
LIMIT 0,
10



How do I get the row number of post ID 108 in above SQL query? It is in the wp_posts table.


108


wp_posts





This should be quite entry level stuff for someone who has SQL skills.
– Gary Woods
Jun 29 at 10:23





I wonder what the '1=1' filter clause is doing there...
– olleo
Jun 29 at 10:37





@olleo Happy to remove it. :)
– Gary Woods
Jun 29 at 10:39









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift