本文介绍了忽略空格的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行查询以便字段中的空格是
被忽略的最佳方法是什么?例如,以下查询:
SELECT * FROM mytable WHERE username =JohnBobJones
SELECT * FROM mytable WHERE username =John Bob Jones
会找到以下条目:
John Bob Jones
JohnBob Jones
JohnBobJones
我使用php或python,但我认为这没关系。
解决方案
p> SELECT * FROM mytable
WHERE REPLACE(username,'','')= REPLACE(John Bob Jones,'','')
What's the best way to run a query so that spaces in the fields areignored? For example, the following queries:
SELECT * FROM mytable WHERE username = "JohnBobJones"
SELECT * FROM mytable WHERE username = "John Bob Jones"
would find the following entries:
John Bob Jones
JohnBob Jones
JohnBobJones
I am using php or python but I think this doesn't matter.
解决方案
SELECT * FROM mytable
WHERE REPLACE(username, ' ', '') = REPLACE("John Bob Jones", ' ', '')
这篇关于忽略空格的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!