sql return categories ordered by blog post date -


I have a WordPress website with articles in one post or there may be more categories (table wp_terms). Now I want a query that gives a list of all the word names, the order from the date of the blog order. I have experimented with one experiment in a SELECT query, but that is not working ... How can I do this and return the categories described according to the date of the article?

The table will be wp_posts (for example):

  | ID ------ | Post_ title ------------------ | Post_data- | | 1 | Test Title | 2014-05-05 | | 2 | Test Title 2 | 2014-04-01 | | 3 | Last Test Title | 2014-02-02 | | 4 | Another blog item | 2014-01-06 |   

Table wp_terms :

  | Word_id | Name --------- | | 1 | Computer | | 2 | Home | | 3 | Work |   

The table is wp_term_relationships

  | Object_id | Word_takkony_id | Word_order | | 1 | 2 | 0 | | 1 | 1 | 0 | | 2 | 3 | 0 |   

Table wp_term_taxonomy

  | Term_taxonomy_id | Word_id | | 1 | 1 | | 2 | 2 | | 3 | 3 | | 4 | 4 |   

This is my current query, but it does not work right ...

  SELECT t. *, P. * Add wp_term_relationships as TR on tr.term_taxonomy_id = tr.term_taxonomy_id tr as T-join Wp_term_taxonomy AS tt.term_id = t.term_id (`` `` ID`, `post_ title`, select max, as tr `Post_data`)` `` `` `` `` `` `` `tr.`object_id`" by group `t 'in the form of the form` id`) by the wp_posts group. `Tterm_id` ORDER BY p.`date` desc    

is still not sure What are you trying to achieve? But wp_terms_taxonomy as TTT as this wp_terms may include wp_terms_relationship as TR on tt.term_id = t.term_id TR as your query that selects

  without errors Do T runs. *, P. *. Term_taxonomy_id = tr.term_taxonomy_id by the p.ID = tr.object_id group t.term_id as the left id (select ID, POST_TITLE, max (POST_DATE as the basis of the date id from the wp_posts group), POST_TITLE) .name, p.id, p.post_title, p.date by desc   

p.date order

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -