饮歌长啸
这很有趣,但问题也可以通过准备好的陈述来解决(不确定是否适合每个人),例如:mysql> EXPLAIN SELECT * FROM words WHERE word IN (SELECT word FROM phrase_words);+----+--------------------+--------------+...| id | select_type | table |...+----+--------------------+--------------+...| 1 | PRIMARY | words |...| 2 | DEPENDENT SUBQUERY | phrase_words |...+----+--------------------+--------------+...mysql> EXPLAIN SELECT * FROM words WHERE word IN ('twist','rollers');+----+-------------+-------+...| id | select_type | table |...+----+-------------+-------+...| 1 | SIMPLE | words |...+----+-------------+-------+...所以,只需在存储过程中准备语句,然后执行它。以下是一个想法:SET @words = (SELECT GROUP_CONCAT(word SEPARATOR '\',\'') FROM phrase_words);SET @words = CONCAT("'", @words, "'");SET @query = CONCAT("SELECT * FROM words WHERE word IN (", @words, ");";PREPARE q FROM @query;EXECUTE q;