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

LVL 16
hankknightAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
this should do:
SELECT 
            `name`, `description`, `p_street`, `p_city`
      FROM 
            `organizations`
      WHERE
            replace(`name`, ' ', '') = 'helloworld'

Open in new window

0
 
hankknightAuthor Commented:
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

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

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.