Use SQL statements in ASP 3:like, not like and BETWEEN

Source: Internet
Author: User
Tags range
You have seen the use of like in the example where you have taken the W-heading record above. The like decision word is a very useful symbol. However, in many cases it may give you too much data, so it's a good idea to think about what data you want to get before you use it. Suppose you want to take out a 5-digit SKU number, and it starts with 1 at the end of 5, you can use the caret (_) instead of the% symbol:
SQL = "SELECT * WHERE p_sku like ' 1___5 '"

The following stroke denotes any one character. So in the case of the input "1 _ _ _ 5", your search will be limited to the 5-digit range that meets the specific pattern.

If you want to do the opposite, find all SKU entries that do not match the "1_ _ 5" mode. Then you just need to add not to the like in the example in the statement just now.

BETWEEN
If you want to take out a range of data, and you know the starting and ending points of the range, then you might as well use a between judgment word. Now let's assume that you want to select a record within a given table that ranges between 1 and 10. You can use between as follows:
... WHERE ID BETWEEN 1 and 10

Or you can use the already familiar mathematical judgment words:
... WHERE ID >= 1 and ID >= 10



Related Article

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.