Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Paste Description for Wordpres Mysql cheat-sheet

Handy queries. Not as trivial as one would think :) http://wordpress.org/support/topic/242658

Tested on Wordpress 2.7.1

Wordpres Mysql cheat-sheet
Saturday, February 21st, 2009 at 4:27:11am MST 

  1. /* All posts of category 'recipes' */
  2. SELECT id,post_title
  3.     FROM wp_term_taxonomy
  4.         JOIN wp_terms
  5.             ON wp_term_taxonomy.term_id = wp_terms.term_id
  6.         JOIN wp_term_relationships
  7.             ON wp_term_taxonomy.term_taxonomy_id
  8.                 = wp_term_relationships.term_taxonomy_id
  9.         JOIN wp_posts
  10.             ON wp_term_relationships.object_id = wp_posts.id
  11.    WHERE wp_term_taxonomy.taxonomy='category' AND name='recipes'
  12.        AND post_type='post' AND post_status='publish'
  13.    ORDER BY id DESC
  14.  
  15. /* all tags and number of posts for each (tag cloud) */
  16. SELECT wp_terms.name,
  17.        count(wp_term_relationships.object_id) AS num_posts
  18.     FROM wp_term_taxonomy
  19.         JOIN wp_terms
  20.             ON wp_term_taxonomy.term_id = wp_terms.term_id
  21.         JOIN wp_term_relationships
  22.             ON wp_term_taxonomy.term_taxonomy_id
  23.                 = wp_term_relationships.term_taxonomy_id
  24.         JOIN wp_posts
  25.             ON wp_term_relationships.object_id = wp_posts.id
  26.    WHERE wp_term_taxonomy.taxonomy='post_tag'
  27.        AND post_type='post'
  28.        AND post_status='publish'
  29.    GROUP BY wp_terms.term_id
  30.    ORDER BY name ASC
  31.  
  32. /* All posts of with tag 'spicy' */
  33. SELECT id,post_title
  34.     FROM wp_term_taxonomy
  35.         JOIN wp_terms
  36.             ON wp_term_taxonomy.term_id = wp_terms.term_id
  37.         JOIN wp_term_relationships
  38.             ON wp_term_taxonomy.term_taxonomy_id
  39.                 = wp_term_relationships.term_taxonomy_id
  40.         JOIN wp_posts
  41.             ON wp_term_relationships.object_id = wp_posts.id
  42.    WHERE wp_term_taxonomy.taxonomy='post_tag' AND name='spicy'
  43.        AND post_type='post' AND post_status='publish'
  44.    ORDER BY id DESC

Paste Details

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation