Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

PHP/mySQL Search: ignore spaces

I want to ignore spaces in my search.

So these would return the same results:
    Hello World
and
    helloworld
and
    he llow orld


SELECT 
		`name`, `description`, `p_street`, `p_city`
	FROM 
		`organizations`
	WHERE
		`name` = 'helloworld'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hankknight

ASKER

This does not work for me because I need it to work with a partial match.



SELECT 
            `name`, `description`, `p_street`, `p_city`
      FROM 
            `organizations`
      WHERE
            replace(`name`, ' ', '') = '%elloworl%'

Open in new window

I figured it out, thanks!
SELECT 
            `name`, `description`, `p_street`, `p_city`
      FROM 
            `organizations`
      WHERE
            replace(`name`, ' ', '') LIKE '%elloworl%'

Open in new window