Reputation: 7097
I want to display a result of ADSTech
with the help of like Statement using ADS Technology
keyword in MySQL like this
SELECT * FROM subcategories WHERE `name` LIKE '%ADS Technology%'
This result is required
Also see my database screenshot
Upvotes: 0
Views: 143
Reputation: 13394
If I understood your question clearly, You can use any of the following query to get the results related to ADSTech or ADS Technology....
SELECT * FROM subcategories WHERE `name` LIKE '%ADSTech%' OR `name` LIKE '%ADS Technology%';
SELECT * FROM subcategories WHERE `name` IN ('ADSTech','ADS Technology');
Good Luck,
Upvotes: 1
Reputation:
It will not search because it's considering space.
you need to either remove space from keyword using before passing in query
$string_without_whitespaces = str_replace(' ', '', $string);
OR
$string_without_whitespaces = preg_replace('~\s~', '', $string);
OR split your keyword from space, like if using PHP use explode()
and run your query around this array as per your needs.
$key=explode("",$keyword);
then
$query="SELECT * FROM subcategories WHERE `name` LIKE '%".$key[1]."%' OR '%".$key[2]."'";
OR
$query="SELECT * FROM subcategories WHERE `name` LIKE '%".$key[1].$key[2]."%'";
Upvotes: 2
Reputation: 6837
You could have a table which stores aliases for companies and then use that in the like as follows:
SELECT *
FROM subcategories sc, companyalias ca
WHERE ca.primaryname LIKE '%ADS Technology%'
AND ca.name = sc.name
Upvotes: 0