SQL JOIN syntax? help!
-
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_nametable: wp_post2cat
field: post_id
field: category_idtable: wp_categories
field: category_nicename
field: cat_IDThe 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
- The topic ‘SQL JOIN syntax? help!’ is closed to new replies.