【问题标题】:remove whitespaces on query mySQL删除查询 mySQL 上的空格
【发布时间】:2013-09-30 08:58:23
【问题描述】:

在名为Postcodes 的数据库表中,我有AB10 1ABAB10 2AB 之类的行

所以当我拉他们访问动态页面时,他们出现在像 AB10%201AB 这样的 URL 中,显然是因为或被 URL 编码,现在我如何将 URL 设置为 AB101AB,然后仍然访问使用AB101AB的数据库行?

简而言之,我想使用AB101AB访问数据库中值为AB10 1AB的行

类似

SELECT 
    * 
FROM 
    `Postcodes` 
WHERE 
    `postcode` = REMOVEWHITESPACES FROM `postcode` ROW('AB101AB')

【问题讨论】:

标签: php mysql sql


【解决方案1】:

使用replace()函数(参考here):

select *
from `Postcodes`
where replace(`postcode`, ' ', '') = 'AB101AB'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-02
    • 2014-12-23
    • 1970-01-01
    • 2021-06-20
    • 1970-01-01
    • 2020-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多