[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP/mySQL Search: ignore spaces

Posted on 2009-04-21
3
Medium Priority
?
322 Views
Last Modified: 2013-12-12
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

0
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 24195919
this should do:
SELECT 
            `name`, `description`, `p_street`, `p_city`
      FROM 
            `organizations`
      WHERE
            replace(`name`, ' ', '') = 'helloworld'

Open in new window

0
 
LVL 16

Author Comment

by:hankknight
ID: 24196588
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
 
LVL 16

Author Comment

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

Open in new window

0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month19 days, 3 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question