Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
Where do you get this error? Also, try to disable all plugins and enable them one by one, to see if this is a problem with a plugin, and if so, which. You can try the same with themes by switching back to a default theme (Twenty Twelve, Twenty Eleven, ...). – Camil Staps Mar 16 at 12:37

1 Answer

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).

share|improve this answer
Already try to disable all plugins try to find r.object_id, r.term_taxonomy_id, same error – RAN Mar 16 at 16:13
I don't know where that code is coming from but I am fairly sure about the problem with the code you posted. Can't you [grep](r.term_taxonomy_id = x.term_taxonomy_id) your install for r.term_taxonomy_id = x.term_taxonomy_id to find the code? – s_ha_dum Mar 16 at 22:35
Thank you for you help. Already resolved. – RAN Mar 17 at 8:41
You should consider posting the solution for the benefit of anyone else who might have this problem. – s_ha_dum Mar 17 at 14:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.