Home >Backend Development >PHP Tutorial >Notes on MySQL's varchar type
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.