• Resolved jwilliams

    (@jwilliams)


    This question pertains to my WordPress database. I need to JOIN 3 SQL tables to extract information from the wp_comments table.

    dbname: wordpress

    table: wp_comments
    field: ID
    field: post_name

    table: wp_post2cat
    field: post_id
    field: category_id

    table: wp_categories
    field: category_nicename
    field: cat_ID

    The idea is that wp_comments.ID = wp_post2cat.post_id, and wp_post2cat.category_ID = wp_categories.cat_ID

    I need a properly syntaxed SQL query written as a string for a php variable, $query. I’ve written the gernal idea out below, where things inside need to be put into proper SQL

    $query=”SELECT [[wp_comments.ID, wp_comments.post_name]] FROM all three tables WHERE [[wp_categories.category_nicename=SomeCategoryName]] ORDER [[by wp_comments.ID, descending]] LIMIT [[to $delimiter, a php variable]]”

    If you are an SQL buff and have a spare moment, I’d REALLY apreciate a moment of your time to help me out here! Thanks so much – Jameson

Viewing 1 replies (of 1 total)
  • Thread Starter jwilliams

    (@jwilliams)

    Oh. I can just require_once(‘./blog/wp-config.php’); and then use all those query_posts() options before including the loop on any damn page i feel like outside of ./blog!

    WordPress just got like, five hundred times cooler for me. What a joke to think I had to know that complicated database query! Ha.

    Sorry, I’m excited.

Viewing 1 replies (of 1 total)
  • The topic ‘SQL JOIN syntax? help!’ is closed to new replies.