Please tell me what is wrong with the code?

I get the error: Unknown column 't.entry_id' in 'on clause'

I understand the problem in the line LEFT JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id

Here is the full request.

 SELECT t.entry_id AS entry_id , t.title AS title , t.weblog_id, t.url_title AS url_title , t.entry_date AS entry_date,COUNT(*) FROM exp_weblog_titles AS t ,(select title ,entry_date ,entry_id from exp_weblog_titles where weblog_id=3 ) as newsreal LEFT JOIN exp_category_posts ON t.entry_id = exp_category_posts.entry_id WHERE newsreal.title LIKE CONCAT('%', t.title, '%') AND t.site_id IN ('1') AND t.status = 'open' AND t.weblog_id = 13 AND newsreal.entry_date > UNIX_TIMESTAMP() - 3600*24*7 AND exp_category_posts.cat_id = 59 GROUP BY title ORDER BY COUNT(*) DESC LIMIT 20 
  • Well, miracles do not happen, so in exp_weblog_titles there is no entry_id column - Mike
  • There are, in fact of the matter. Without LEFT JOIN everything works. But you need to pick up a category. - Stanislav
  • So swap the subquery and the table t that the left join really divided the tables that are in on (although this is strange) - Mike
  • Thank you, everything worked :) - Stanislav

1 answer 1

Reply from comments from Mike

Swap the subquery and the table t that the LEFT JOIN really separates the tables that are in the ON construct.