I have two tables with a lot of rows and I need to maintain "index" informations for each row in the first (table_1). So I wrote a query to not use directly COUNT() [wich is slow, slow, slow]. So I try :
UPDATE table_1 SET table_1.column_3 = ( SELECT COUNT(*) FROM ( SELECT DISTINCT column_5 FROM table_2 WHERE table_2.id_t1 = table_1.id LIMIT 300 ) t )
But MySQL answering me that table_1.id is unknow in where clause (#1054)
Did you know how to passs table_1.id in the where clause ? Or other way to get my goal ?
Thank you for helping me !