Home >php教程 >php手册 >MySQL的varchar类型注意事项,mysqlvarchar

MySQL的varchar类型注意事项,mysqlvarchar

WBOY
WBOYOriginal
2016-06-13 08:49:471000browse

MySQL的varchar类型注意事项,mysqlvarchar

  前几天就在工作中发现这样一个问题:当某个字段的类型为varchar时,字段保存的值类似'100,200,300'  和 '100' 或 '100,400'。写SQL语句的时候就会犯这样的错误,例如:

select id,provinceid from admin where provinceid in ('100'<span>);

select id</span>,provinceid from admin where provinceid in (100);

  会发现上面2条SQL的查询结果并不相同,正确的SQL是第2条。因为字段保存的值类似'100,200,300',并不是'100','200','300'这样的值,所以第2条的SQL才正确。

 

 
Statement:
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