• Resolved markval

    (@markval)


    Hi all,

    I want to make a Query in phpMyAdmin to return post from a category.

    I think I have to make a combination of :
    wp_posts
    wp_terms
    wp_term_relationships
    wp_term_taxonomy

    I am a ActionScript developper who’s building a Framework to display WP post in Flash using AMFphp and 90% of it is done. I don’t play often in MySQL Query. Any help would be greatly appreciated and my Framework will be OpenSource once finalized.

    Regards,
    Mark

Viewing 4 replies - 1 through 4 (of 4 total)
  • This query lists post ids and their asscoiated categorys

    select wpr.object_id, wp_terms.name from wp_terms inner join wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id inner join wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id wheretaxonomy= "category" order by object_id;

    So you could limit that appropriately with the where clause as needed.

    Or for a more expansive version with better clarity –

    select p.post_title, wpr.object_id, wp_terms.name
    from wp_terms
    inner join wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id
    inner join wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
    inner join wp_posts p on p.ID = wpr.object_id
    where taxonomy= “category” and p.post_type = ‘post’
    order by object_id;

    Thread Starter markval

    (@markval)

    Wow this will help me out a lot!

    Thank you very much!

    I do understand how it works now and it is pretty simple in some way!

    Not to dredge up an old post, but is there a way to actually limit which category is pulled. Meaning, instead of pulling all posts listed by category, how could I pull posts only in one category?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SQL Query :: SELECT post from category ?’ is closed to new replies.