Home >Backend Development >PHP Tutorial >Notes on MySQL's varchar type

Notes on MySQL's varchar type

WBOY
WBOYOriginal
2016-07-29 09:10:32828browse

 I discovered such a problem at work a few days ago: when the type of a field is varchar, the values ​​stored in the field are similar to '100, 200, 300' and '100' or '100,400'. You will make such mistakes when writing SQL statements, for example:

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

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

You will find that the query results of the above two SQLs are not the same, and the correct SQL is the second one. Because the values ​​stored in the field are similar to '100, 200, 300', not '100', '200', '300', the SQL in item 2 is correct.

The above introduces the precautions for MySQL's varchar type, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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