紧急求救MySQL中多个空格问题! 项目中有这样一个需求,或者说可能,就是用户会输入多个空格作为自己的密码,而当保存到MYSQL中时,MYSQL会当作一个空格进行存储,这样在搜索的时候,无论输入几个空格作为搜索条件,结果都一样,请问有什么办法可以解决吗?或者说对于MYSQL,这个问题无解? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谁说的。这两个结果就不一样。select password(' '),password(' ');结果*89F79AE862AF0A89753E2C97CF2B628B28C5B564 *5C989A26E8BA4421E925935D8624BC0629F699D8 恩恩,利用password函数是个好办法,但是他原有的数据库设计中,是直接把密码不经过转换存进去的,所以要改就改动大了,有其他方法吗? 那你就传之前判断他的长度。具体看lpad函数。 还有个问题是,如果使用这个函数的话,搜索的时候就可能没办法了SELECT * FROM t0 WHERE C1 = password(' ');查不出结果~ 给你个例子,不知道你是怎么测试的。mysql> create table space_save( -> id int not null AUTO_INCREMENT PRIMARY key, -> space_field varchar(255) not null -> )engine=myisam;Query OK, 0 rows affected (0.03 sec)mysql>mysql> insert into space_save(space_field) values -> (password(' ')), -> (password(' ')), -> (password(' ')), -> (password(' '));Query OK, 4 rows affected (0.00 sec)Records: 4 Duplicates: 0 Warnings: 0mysql>mysql> select * from space_save where space_field = password(' ');+----+-------------------------------------------+| id | space_field |+----+-------------------------------------------+| 1 | *1A256E4E2FE95B8BF7349C168991EA8035D1359B |+----+-------------------------------------------+1 row in set (0.00 sec)mysql> select * from space_save where space_field = password(' ');+----+-------------------------------------------+| id | space_field |+----+-------------------------------------------+| 2 | *5C989A26E8BA4421E925935D8624BC0629F699D8 |+----+-------------------------------------------+1 row in set (0.00 sec)mysql> select * from space_save where space_field = password(' ');+----+-------------------------------------------+| id | space_field |+----+-------------------------------------------+| 3 | *CB79A6814789720143FACC8A1FBD2347193BCBF4 |+----+-------------------------------------------+1 row in set (0.00 sec)mysql> select * from space_save where space_field = password(' ');+----+-------------------------------------------+| id | space_field |+----+-------------------------------------------+| 4 | *D91B68729F5831028CF9B6CB5D0340F9BA69D643 |+----+-------------------------------------------+1 row in set (0.00 sec)mysql> OK~查到原因了,数据库设计的时候密码字段的长度是20,所以把PASSWORD函数转化的密码给截断了,所以无法再去匹配了,万分感谢你的大力帮助,现在结帖给分~~ 关于 mysql 查询 in 参数的个数限制 添加字段问题 那位高手来给我解决一下【没有什么分,只是希望大家能从技术的角度帮我】 请教一个联合查询的问题。 AUTO_INCREMENT 是不是必须设成主键 mysql主键之外字段的自增 老问题!Mysql中文问题?jsp+myql+linux+tomcat--->寻求高手^_^ 能不能将MYSQL的数据库转化为ACCESS的? phpmyadmin导出导出数据库出现问题 请教一个关于deadlock 死锁的问题 如何修改产生binlog文件的大小 一个SQL 语句的问题
*89F79AE862AF0A89753E2C97CF2B628B28C5B564 *5C989A26E8BA4421E925935D8624BC0629F699D8
具体看
lpad函数。
SELECT * FROM t0 WHERE C1 = password(' ');查不出结果~
-> id int not null AUTO_INCREMENT PRIMARY key,
-> space_field varchar(255) not null
-> )engine=myisam;
Query OK, 0 rows affected (0.03 sec)mysql>
mysql> insert into space_save(space_field) values
-> (password(' ')),
-> (password(' ')),
-> (password(' ')),
-> (password(' '));
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0mysql>
mysql> select * from space_save where space_field = password(' ');
+----+-------------------------------------------+
| id | space_field |
+----+-------------------------------------------+
| 1 | *1A256E4E2FE95B8BF7349C168991EA8035D1359B |
+----+-------------------------------------------+
1 row in set (0.00 sec)mysql> select * from space_save where space_field = password(' ');
+----+-------------------------------------------+
| id | space_field |
+----+-------------------------------------------+
| 2 | *5C989A26E8BA4421E925935D8624BC0629F699D8 |
+----+-------------------------------------------+
1 row in set (0.00 sec)mysql> select * from space_save where space_field = password(' ');
+----+-------------------------------------------+
| id | space_field |
+----+-------------------------------------------+
| 3 | *CB79A6814789720143FACC8A1FBD2347193BCBF4 |
+----+-------------------------------------------+
1 row in set (0.00 sec)mysql> select * from space_save where space_field = password(' ');
+----+-------------------------------------------+
| id | space_field |
+----+-------------------------------------------+
| 4 | *D91B68729F5831028CF9B6CB5D0340F9BA69D643 |
+----+-------------------------------------------+
1 row in set (0.00 sec)mysql>