I have a column in MYSQL named 'text', and it has one value: "He?llo?". I'm trying to get the value "He?llo?" where using the equal to "Hello" to get it. It doesn't equal because "He?llo?" has 2 question marks inside of it, and "Hello" has none. My question is, is there a way to somehow remove the 2 question marks from "He?llo?" before comparing it to "Hello", so that it equals?
$text = "Hello";
SELECT text FROM table WHERE text = '$text';
You can use replace()
:
SELECT text
FROM table
WHERE replace(text, '?', '') = '$text';
You could use replace
as many times as you like. But this way of proceeding will require a full table scan, and if your table has many rows this is inefficient.
There are two alternatives :
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.