mysql> SELECT id, word, object_count FROM ezsearch_word where word='na' ORDER BY object_count; +-------+------+--------------+ | id | word | object_count | +-------+------+--------------+ | 17585 | nĂ¥ | 101 | ***NB!*** | 24992 | na | 503 | ***NB!*** +-------+------+--------------+ 2 rows in set (0.00 sec) mysql> CREATE TEMPORARY TABLE ezsearch_tmp_0 ( contentobject_id int primary key not null, published int ); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO ezsearch_tmp_0 SELECT DISTINCT ezsearch_object_word_link.contentobject_id, ezsearch_object_word_link.published -> FROM ezcontentobject, -> ezsearch_object_word_link -> , -> ezcontentclass, -> ezcontentobject_tree -> -> WHERE -> -> -> -> ***NB!*** -> ezsearch_object_word_link.word_id='17585' AND -> -> ezcontentobject.id=ezsearch_object_word_link.contentobject_id and -> ezcontentobject.contentclass_id = ezcontentclass.id and -> ezcontentclass.version = '0' and -> ezcontentobject.id = ezcontentobject_tree.contentobject_id and -> ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id; Query OK, 70 rows affected (0.00 sec) Records: 70 Duplicates: 0 Warnings: 0 mysql> CREATE TEMPORARY TABLE ezsearch_tmp_1 ( contentobject_id int primary key not null, published int ); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO ezsearch_tmp_1 SELECT DISTINCT ezsearch_object_word_link.contentobject_id, ezsearch_object_word_link.published -> FROM -> ezcontentobject, -> ezsearch_object_word_link -> , -> ezcontentclass, -> ezcontentobject_tree, -> ezsearch_tmp_0 -> -> WHERE -> ezsearch_tmp_0.contentobject_id=ezsearch_object_word_link.contentobject_id AND -> -> -> -> ***NB!*** -> ezsearch_object_word_link.word_id='24992' AND -> -> ezcontentobject.id=ezsearch_object_word_link.contentobject_id and -> ezcontentobject.contentclass_id = ezcontentclass.id and -> ezcontentclass.version = '0' and -> ezcontentobject.id = ezcontentobject_tree.contentobject_id and -> ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id; Query OK, 0 rows affected (0.00 sec) Records: 0 Duplicates: 0 Warnings: 0