你能否告訴我這兩句話哪一句更快?mysql - 「INNER JOIN」或「IN」。哪個更快?
第一句:
SELECT DISTINCT(t1.user_id) FROM table_users as t1 WHERE t1.user_town IN (SELECT t2.town FROM table_towns as t2)
第二個句子:
SELECT DISTINCT(t1.user_id) FROM table_users as t1
INNER JOIN (SELECT t2.town FROM table_towns as t2) as t3 ON t1.user_town = t3.town
我使用的選擇通常是複雜一點。 而且,如果可能,我嘗試使用IN(...),因爲我可以傳遞值或表格選擇。
我已經將SELECT t1。*的結果更改爲SELECT DISTINCT(t1.user_id)以避免不同的結果。因爲它通常是我真正關心的 – Seeker