SQL Server 7.0 (2)

Source: Internet
Author: User
Tags numeric value
Access data
Select statement
1. Select all columns in the table
"*" Has special significance for Select statements. It specifies all columns in the table, instead of column names. The column order is the same as that in the table.
2. Select different values
If the column in the selected list contains duplicate values, the "distinct" keyword can be used to ignore duplicate values.
Note: if the Select list contains more than one column, the distinct keyword is generally valid for them. If a column has duplicate values and the values of other columns are unique, a column with duplicate values is included in the result.
3. Rename columns in the result dataset
The default name of the column in the result is the name of the column in the source database. You can replace the default name with the name you specified.
Select AuthorFirstName = au_fname from authors
-- Change the column name from "au_fname" to "AuthorFirstName"
4. Select calculation value
The Select list can contain computing values or constants. The calculated value is calculated based on an arithmetic expression. It can contain one or more columns in a table.
Select totalSale = price * ytd_sales from titles
Conditional selection (Where clause)
Use a comparison or logical operation to specify a filter condition in the Where clause to generate the expected rows in the table.
1. Comparison
The comparison operation can compare the numeric value, character, and date data. The return value is TRUE or FALSE.
Comparison operator
<(Less)
> (Greater)
= (Equal)
<> (Not equal)
> = (Greater than or equal)
<= (Less than or equal)
! = (Not equal)
! <(Not less)
!> (Not greater)
2. Logical operations
Perform a logical operation to test whether certain conditions are correct and return TRUE or FALSE based on the test results.
· LIKE if the operation is the same as the specified string, TRUE is returned. The specified string can also contain wildcards.
The like operation with wildcard characters is more useful.
· "%" Indicates that all strings can replace the character "%. Any specified string before or after "%" is considered as a constant. For example, "New %" indicates all strings starting with "New", and "% New" indicates strings ending with "New.
· "_" Specifies that any single character can be substituted into the "_" position. This is useful when only one character is different from similar characters.
· "[]" Requires that one character be replaced by a character defined in square brackets. The square brackets may contain independent characters (such as [ahg]), or the character range (such as [c-I]).
· "[^]" Indicates that the character after "^" in square brackets cannot be used for substitution. It can be an independent character (such as [ahg]). it can also be a character range (for example, [c-I]).
Note: you can combine these wildcards in an expression.
· BETWEEN Returns TRUE if the operand is within the provided range.
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.