if logic judgment in shell scripts
Logical judgment Expression:
-GT (>); Greater than great than
-lt (
If logical judgment format:
Format 1:if condition; Then statement; Fi
format 2:if condition; then statement; Else statement; Fi
format 3:if ...; Elif ...; Then ...; else ...; Fi
--
can use | | Combine multiple conditions
a conditions b:a and b
conditions a| | Condition b:a or b
if [$a-gt 5] [$a-lt]; then
if [$b-gt 5] | | [$b-lt 3]; Then
F
a number:" NIf [-Z "$n"]Thenecho "Null,please input a number."Exit 1Exit 1 indicates the return value after executing the partial commandThat is, when the command finishes executing, use echo $? The valueFin1=echo $n | sed ‘s/[0-9]//g‘Change the number in variable N to null and assign to N1If [-N "$n 1"]Determines if the N1 is not empty, then outputs the following result, and is empty to continue executionThenecho "Please input a number."Exit 1FiIf [$n-lt] [$n-ge 0]ThenTag=1elif [$n-ge] [$n-L
The CASE expression returns a value based on the conditional logic.
In the development process, we often need to return a value for a column based on the conditional logic. In this CASE, we need to use the CASE expression.
For example, the following query of the Products tab
Tags: here Select traffic Results Isolation LEVEL SEL level size catIn general, database optimization can be divided into 4 aspects from the hardware level:CPU: That is, reduce the computational complexity, such as reducing the various types of SQL aggregation functions, window functions, case when and so on.IO: (Less access to data during query result set.) Data optimization from here to a great extentNetwork: Less query result set size, eliminate un
In our development process, we often need to return a value for a column, based on conditional logic, then we need to use the case expression.
For example, the following query to the Products table uses a CASE expression in the SELECT statement to generate information that describes the value of the CategoryID column.
The SQL code is as follows:
--Setting
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.