SQL IN ASP: LIKE, NOT LIKE & BETWEEN

xiaoxiao2021-03-06  75

You have seen the LIKE usage in the example of remaining the W header record. The Like decision is a very useful symbol. However, in many cases it uses it to bring you too much data, so it is best to open your mind before you use it. Suppose you want to take a 5-digit SKU number, and the beginning is 1 end is 5, then you can use the underman (_) replace the% symbol: SQL = "SELECT * from Products where p_sku like '1___5'"

The underscription indicates any character. So in the case of entering "1___5", your search is limited to the 5-digit range that meets a specific mode.

If you want to go against it, you have to find the SKU entry that does not match the "1___5" mode. Then you only need to add NOT in front of the LIKE in the examples just now.

Between assumes that you want to take out some range of data, and you know the starting point and end point in advance, then you may wish to use BetWeen judgment. Let us now assume that you want to select the records between 1 and 10 in a given table. You can use Between: ... WHERE ID BETWEEN 1 and 10

Or you can also use a familiar mathematical judgment sentence: ... WHERE ID> = 1 and ID> = 10

转载请注明原文地址:https://www.9cbs.com/read-121768.html

New Post(0)