忽略空格的查询
运行查询的最佳方法是什么,以便字段中的空格是无视?例如,以下查询:
What's the best way to run a query so that spaces in the fields are ignored? For example, the following queries:
SELECT * FROM mytable WHERE username = "JohnBobJones"
SELECT * FROM mytable WHERE username = "John Bob Jones"
会找到以下条目:
John Bob Jones
JohnBob Jones
JohnBobJones
我使用的是 php 或 python,但我认为这无关紧要.
I am using php or python but I think this doesn't matter.
推荐答案
SELECT * FROM mytable
WHERE REPLACE(username, ' ', '') = REPLACE("John Bob Jones", ' ', '')
相关文章