WordPress error since update 3.2.1 to 3.5.1-Collection of common programming errors

Since I have updated wordpress 3.2.1 to 3.5.1 I have this error. One month looking for this error and so far, I can not find a solution even know what file causing this error.

[16-Mar-2013 11:36:35 UTC] Erro na base de dados do WordPress Unknown column `'wp_term_relationships.term_taxonomy_id'` in `'where clause'` na query 

SELECT SQL_CALC_FOUND_ROWS  wp_posts.*, 
IF( wp_posts.ID IN (
337,225,673,12,6719,7880,11242,27505,34630,10551,38533,38531), 1, 0) AS featured 
FROM wp_posts  
INNER JOIN wp_term_relationships AS r ON (wp_posts.ID = r.object_id)  
INNER JOIN wp_term_taxonomy AS x ON (r.term_taxonomy_id = x.term_taxonomy_id)  
AND (x.taxonomy = 'ad_tag' OR x.taxonomy = 'ad_cat' OR 1=1)  
INNER JOIN wp_postmeta AS m ON (wp_posts.ID = m.post_id)  
INNER JOIN wp_terms AS t ON x.term_id = t.term_id  
WHERE 1=1  AND ( wp_term_relationships.term_taxonomy_id IN (726) ) 
AND wp_posts.post_type IN ('post', 'page', 'attachment', 'ad_listing') 
AND (wp_posts.post_status = 'publish') 
GROUP BY wp_posts.ID 
ORDER BY featured DESC, wp_posts.post_date DESC LIMIT 0, 10 

feita por require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts

  1. This is really a pure MySQL questions but what you’ve done is JOIN wp_term_relationships as r

    INNER JOIN wp_term_relationships AS r ON (wp_posts.ID = r.object_id)

    , which means that there is no table in the query scope named wp_terms_relationships. That table is aliased as r. Yet your code tries to access wp_term_relationships

    AND ( wp_term_relationships.term_taxonomy_id IN (726) ).

    That should be AND ( r.term_taxonomy_id IN (726) ) as in a couple of other places in the query. For example, INNER JOIN wp_term_taxonomy AS x ON (r.term_taxonomy_id = x.term_taxonomy_id).

Originally posted 2013-11-10 00:12:41.