CREATE TABLE `testtel` (
`tel` varchar(25) default NULL,
) TYPE=MyISAM;INSERT INTO `testtel` (`tel`) VALUES
('020-1234567'),
('123456789000'),
('1234567899'),
('012345678999'),
('075785334563'),
('13612345678'),
('02012345678'),
('02012399995'),
('020-12345679-123');mysql> select tel from testtel
-> where MATCH (tel) AGAINST ('123456*' IN BOOLEAN MODE)
-> ;
+------------------+
| tel |
+------------------+
| 020-1234567 |
| 123456789000 |
| 1234567899 |
| 020-12345679-123 |
+------------------+
4 rows in set (0.00 sec)我想要的结果是:
+------------------+
| tel |
+------------------+
| 020-1234567 |
| 123456789000 |
| 1234567899 |
| 012345678999 |
| 13612345678 |
| 02012345678 |
| 020-12345679-123 |
+------------------+
不要用like的方式:select tel from testtel where tel like '%123456%'
因为真正运行时,有几十万甚至百万的数据,如果用like时间好长。
用MATCH的方式怎样才能得到我要的结果
CREATE TABLE `testtel` (
`tel` varchar(25) default NULL,
FULLTEXT KEY `tel` (`tel`)
) TYPE=MyISAM;