I have a question regarding some SQL statement. I search for a name, e.x. "Anne Marie Parker". This search query I pass over to my script.
The script uses the following sql code:
SELECT * FROM table WHERE name LIKE '%(searchquery)%'
(searchquery) will be the name I am looking for.
The issue is the following. I not only want to get Anne Marie Parker as a result, I also want to get results with "Anne Parker".
Is there any possibility to do this in my sql query? I could prepare it by code, but I want it to be done in my sql query.
Is there some kind of function like replace all spaces with "%" which will then be interpreted by the regex?
Thank you very much and have a nice day!
Bye, WorldSignia
str_replaceorregexp_replacethat can do this, but the details vary between vendors, so we'll need to know what database (Oracle, MySQL, PostgreSQL,...) before we can answer for sure. Look up "string replacemente" in your DB manual if you can.SELECT * FROM table WHERE name LIKE '%Anne%Parker%'this returns what you want