MySQL type of varchar considerations

Source: Internet
Author: User

The problem was found in the work a few days ago: When a field is of type varchar, the field holds values similar to ' 100,200,300 ' and ' 100 ' or ' 100,400 '. When you write a SQL statement, you make such a mistake, such as:

Select Id,provinceid from admin where Provinceid in (' N '); select id, provinceid from admin where Provinceid in ( 100);

You will find that the above 2 SQL query results are not the same, the correct SQL is the 2nd article. Because the field holds a value like ' 100,200,300 ', not a value such as ' 100 ', ' 200 ', ' 300 ', the SQL for 2nd is correct.

MySQL type of varchar considerations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.