Re: mysql Pattern Matching
| From: | CPT John W. Holmes | Date: | Fri, 05 Sep 2003 17:13:26 +0000 |
| Subject: | Re: mysql Pattern Matching | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-161787@lists.php.net to get a copy of this message | ||
From: "Ralph Guzman" <ralph213@sbcglobal.net>
> Is there an advantage or difference in running FIND_IN_SET() instead of
> LIKE?
Actually no, I guess there isn't. Neither one will use an index.
mysql> desc test;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| b | varchar(50) | | MUL | | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.01 sec)
mysql> explain select * from test where b like '%two%';
+-------+--------+---------------+------+---------+------+------+-------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-------+--------+---------------+------+---------+------+------+-------+
| test | system | NULL | NULL | NULL | NULL | 1 | |
+-------+--------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)
mysql> explain select * from test where find_in_set('two',b);
+-------+--------+---------------+------+---------+------+------+-------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-------+--------+---------------+------+---------+------+------+-------+
| test | system | NULL | NULL | NULL | NULL | 1 | |
+-------+--------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)
---John Holmes...