Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>They are the same.</p> <p><strong>Edit</strong>: They are the same in MySQL.</p> <p><em>using an index:</em></p> <pre><code>mysql&gt; explain select * from trees where id = 1 or id = 2; +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | 1 | SIMPLE | trees | range | PRIMARY | PRIMARY | 8 | NULL | 2 | Using where | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ mysql&gt; explain select * from trees where id in (1,2); +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ | 1 | SIMPLE | trees | range | PRIMARY | PRIMARY | 8 | NULL | 2 | Using where | +----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+ </code></pre> <p><em>using a full table scan:</em></p> <pre><code>mysql&gt; explain select * from trees where version = 1 or version = 2; +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | 1 | SIMPLE | trees | ALL | NULL | NULL | NULL | NULL | 7 | Using where | +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ mysql&gt; explain select * from trees where version in (1,2); +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | 1 | SIMPLE | trees | ALL | NULL | NULL | NULL | NULL | 7 | Using where | +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload