You have seen the LIKE usage in the example of getting the w-header record above. LIKE is a very useful symbol. However, in many cases, using it may bring you too much data, so before using it, you 'd better start thinking about what data you want. Assume that you want to retrieve the SKU number with five digits and start with "1" and end with "5", you can use the underscore (_) to replace the "%" symbol:
SQL = "SELECT * FROM Products WHERE p_sku LIKE '1 ___ 5 '"
The delimiter represents any character. Therefore, when "1 _ 5" is entered, your search will be limited to a 5-digit range that meets the specific mode.
If you want to do the opposite, you need to find all SKU entries that do not match the "1 _ 5" mode. Then you only need to add NOT before LIKE in the preceding statement example.
BETWEEN
If you want to retrieve data within a certain range, and you know the start and end of the range in advance, you may wish to use BETWEEN to determine the word. Now let's assume that you want to select a record with a range of 1 and 10 in a given table. You can use BETWEEN as follows:
... Where id between 1 AND 10
Or you can use the familiar mathematical judgment words:
... Where id> = 1 and id> = 10
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.