MySQL比较运算符,空格 [英] MySQL comparison operator, spaces

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

问题描述

如果数据库行是这样的:country = 'usa'并且我查询"select * from data where country = 'usa '",它也会返回该行.所以它不是完全匹配.

If the database row is like this: country = 'usa' and i query "select * from data where country = 'usa '" it also returns this row. So its not an exact match.

为什么MySQL这样做?在其他情况下,如果不是真的,它也会返回TRUE?

Why MySQL does this? And in what other cases it will also return TRUE when its not really true?

推荐答案

如果列的类型为charvarchar,则省略尾随空格;使用like 'usa '解决了问题

The trailing spaces are omitted if the column is of type char or varchar; using like 'usa ' resolves the issue

这篇关于MySQL比较运算符,空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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