忽略空格的查询 [英] Query that ignore the spaces

查看:37
本文介绍了忽略空格的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行查询的最佳方法是什么,以便字段中的空格是无视?例如,以下查询:

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", ' ', '')

这篇关于忽略空格的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆