In a MySQL query, one of the columns in the LEFT JOIN returns “Unknown column”


This might be more of a MySQL question, but since I’m in WordPress I thought I’d start here. Here’s my query:

$persons = $wpdb->get_results(
        'SELECT id, post_name, post_title 
         FROM wp_term_relationships AS tr, wp_posts AS ps 
         LEFT JOIN wp_terms AS wt ON tr.term_taxonomy_id = wt.term_id

and here’s the error that is returned:

WordPress database error: [Unknown column 'tr.term_taxonomy_id' in 'on clause']

We know that term_taxonomy_id is a column in the wp_term_relationships table so I’m not sure why the column is unknown unless there is something about the order of things.

breadwild 2 months 2021-12-02T17:54:11-05:00 0 Answers 0 views 0

Leave an answer