For example, in database i have row with phrase DN-NP
.
In input field i type DN-
and want to find the row.
Here is example http://sqlfiddle.com/#!9/f9235a/4
Tried to use FULLTEXT
index and MATCH AGAINST
SELECT `name`
FROM `domains`
WHERE MATCH (`name`) AGAINST ('DN*' IN BOOLEAN MODE);
get no results.
Here https://dba.stackexchange.com/a/111895/55397 is advice to combine with LIKE
. At the moment idea is in php something like
if( strlen($_POST['input_field_value']) <= 2 ){
$sql = 'SELECT `name`
FROM `domains`
WHERE MATCH (`name`) AGAINST ('DN*' IN BOOLEAN MODE)
OR `name` LIKE "%DN%"';
}
But LIKE "% %" too slow? Any ideas how to solve the problem (to find phrases that contains special characters)?
What about LOCATE
(performance)?
SELECT name AS name7
FROM domains
WHERE LOCATE('DN',`name`)>0;