MYSQL

MYSQL SEARCH EXACT CONTAINS FUZZY

(quick guide & examples)

CASE INSENSITIVE SEARCH SELECT * FROM `TABLE` WHERE `COL` = "SEARCH"

EXACT MATCH SEARCH

01

CASE SENSITIVE SEARCH SELECT * FROM `TABLE` WHERE `COL` = BINARY "SEARCH"

MUST CONTAIN “SEARCH” SELECT * FROM `TABLE` WHERE `COL` LIKE "%SEARCH%"

SEARCH MUST CONTAIN

02

MUST START WITH “SEARCH” SELECT * FROM `TABLE` WHERE `COL` LIKE "SEARCH%"

MUST END WITH “SEARCH” SELECT * FROM `TABLE` WHERE `COL` LIKE "%SEARCH"

EVERYTHING THAT IS "CLOSE ENOUGH" TO "SEARCH" SELECT * FROM `TABLE` WHERE MATCH(`COLUMN`) AGAINST ("SEARCH" IN NATURAL LANGUAGE MODE);

FUZZY SEARCH

03

EITHER A *OR* B MUST CONTAIN "SEARCH" SELECT * FROM `TABLE` WHERE `A` LIKE "%SEARCH%" OR `B` LIKE "%SEARCH%"

SEARCH MULTIPLE COLUMNS

04

BOTH A *AND* B MUST CONTAIN "SEARCH" SELECT * FROM `TABLE` WHERE `A` LIKE "%SEARCH%" AND `B` LIKE "%SEARCH%"