I have a system that searches for company. I want that when a user searches for \"Demo\", all records that have \"Demo\" will be returned, like \"The Demo\", \"Demo Inc.\",
A shot in the dark as per my comment. If you're always going to get an exact match criteria. would it not be best to perform a standard select query?
SELECT * FROM table WHERE company='The Demo'
Or for practical:
$Search = $_GET['company'];
SELECT * FROM table WHERE company='$Search'
Obviously use best practices when working with user input & Queries.
The results drawn will be either the rows found to have The Demo, the demo would be returned or nothing.
If you do not always have an exact match. You could again, use $_GET with an appended value ie $_GET['Exact'] & have two different functions:
function ExactMatch ($DB,$Company){
/*
Query to get exact match as exampled
*/
}
function NotExact($DB,$Company){
/*
Query using LIKE syntax
*/
}
and validate:
if (isset($_GET['Exact'])){
if ($_GET['Exact'] === 1){
ExactMatch($DB,$_GET['Company']);
}else{
NotExact($DB,$_GET['Company'])
}
}
Also, a possible read on DBA.stackexchange:
https://dba.stackexchange.com/questions/39693/how-to-speed-up-queries-on-a-large-220-million-rows-table-9-gig-data