mysql 字段开头空格怎么清除

WBOY
Release: 2016-06-06 20:48:44
Original
2032 people have browsed it

如图所示: mysql 字段开头空格怎么清除

name的字段中,放入的数据前面都会补充空格(PS,前面几个数据是我人工修改的)。这样影响后面的查找。 我用的插入语句是:

insert into user(name,password,email,create_time) VALUES(' $name','$password','$email','$time')"

其中字段name的格式是VARCHAR(45)。网上有两种结局方法,第一是用php的str_replace 函数清除空格和特殊字符,然后依然会补充空格。

第二是用mysql语句的trim,依然会补充空格。

后来我直接把 $name替换成字符串,发现还是空格。

所以我觉得应该是mysql内部的事情,跟踪到这里就进行不下去了。希望能有人进行解答。

回复内容:

如图所示: mysql 字段开头空格怎么清除

name的字段中,放入的数据前面都会补充空格(PS,前面几个数据是我人工修改的)。这样影响后面的查找。 我用的插入语句是:

insert into user(name,password,email,create_time) VALUES(' $name','$password','$email','$time')"

其中字段name的格式是VARCHAR(45)。网上有两种结局方法,第一是用php的str_replace 函数清除空格和特殊字符,然后依然会补充空格。

第二是用mysql语句的trim,依然会补充空格。

后来我直接把 $name替换成字符串,发现还是空格。

所以我觉得应该是mysql内部的事情,跟踪到这里就进行不下去了。希望能有人进行解答。

在name前面还有一个VARCHAR类型的字段,删掉之后就可以了。不明所以~~~

你需要把表的定义发出来看一下。。。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!