我没有收到任何错误,因为这只是一个小问题.
EXPLAIN SELECT a.nid, a.title, a.uid, b.parent, b.weight, c.name, d.value FROM table1 AS a INNER JOIN table2 AS b ON a.vid = b.vid AND a.status = 1 INNER JOIN table3 AS c ON c.uid = a.uid INNER JOIN table4 AS d ON d.content_id = a.nid AND d.value_type = 'percent' AND d.function = 'average'
当我查看哪些表被引用时,一切都很好,但是从table4中它应该只选择"value"字段,我得到一个ALL被称为...
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE a ref PRIMARY,vid,status,uid,node_status_type,nid status 4 const 1 1 SIMPLE b eq_ref PRIMARY PRIMARY 4 databasename.a.vid 1 1 SIMPLE c eq_ref PRIMARY PRIMARY 4 databasename.a.uid 1 Using where 1 SIMPLE d ALL NULL NULL NULL NULL 2 Using where
如您所见,它从决赛桌(d)中选择*.当我只需要从中选择一个字段时,为什么这样做呢?谁能帮我吗?
ALL
表示所有行,而不是所有列.因为它说没有可能的密钥,我猜你没有d.content_id或d.value_type或d.function的索引.
如果您想要花哨,可以在所有这三列中添加索引.