I made a query to get all post in a category in wordpress . I have used JOIN for that and i wanted to arrange all post in a sequence increment created in a new field .
My query is
SELECT * FROM wp_posts p
LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID
LEFT OUTER JOIN wp_term_taxonomy x ON x.term_taxonomy_id = r.term_taxonomy_id
LEFT OUTER JOIN wp_terms t ON t.term_id = x.term_id
WHERE p.post_status = 'publish'
AND p.post_type = 'post'
AND t.slug = 'goat'
The result i am expecting is
row_count id title
1 45 Example
2 67 Example 2
3 104 Example 3
Well how about doing it the wordpress way. I haven’t tested it yet, might need a few tweeks but it should get your your required results.