I need to fetch data from my MySQL database where one column is filled with strings that contains different quotes and apostrophes ( ', ', ` and the classic one ' ).
In my search bar, I want to be able to only write the classic one ' and be able to search for that specific field wheter it contains ', ' or `. For example, I'd like to write " Regie de l'Angleterre " and that it automatically checks " Regie de l'Angleterre " and so on.
Is that possible ?
How can I do something like this in SQL ? I tried to use REPLACE, but couldn't make it work with multiple
My where clause looks like this at the moment.
SELECT realestate_name FROM realestates WHERE REPLACE(realestate_name, ''','\'') LIKE %xxx%
You can use multiple replaces in one select
the Replace function returns string
so you can call another one outside it. Like this
SELECT
realestate_name
FROM realestates
WHERE REPLACE(REPLACE(realestate_name, ''','\''),'’','\'') LIKE %xxx%
SELECT realestate_name FROM realestates WHERE column LIKE '____'
Before you do that, change every single ' " ` and quotation mark and space to %, and put them on the ends
So it would look like this:
Regie de l'Angleterre becomes: %Regie%de%l%Angleterre%
SELECT realestate_name FROM realestates WHERE realestate_name LIKE %Regie%de%l%Angleterre%
This will work & run fine with a not so large database. If you have millions of records, LIKE becomes a nightmare.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.