A concise tutorial on SQL statements in linux --- AND OR, a concise tutorial --- and

Source: Internet
Author: User

A concise tutorial on SQL statements in linux --- AND OR, a concise tutorial --- and

In the previous page, we can seeWHERECommands can be used to select data conditionally in the table. This condition may be simple (like the previous page example) or complex. The complex condition is that two or more simple conditions pass throughANDOrOR. An SQL statement can contain an infinite number of simple conditions.

The syntax for complex conditions is as follows:

SELECT "column name"
FROM "table name"
WHERE "simple condition"
{[AND | OR] "simple condition"} +;

{} + Indicates that one or more occurrences occur. It meansANDAdd simple conditions andORA simple condition can occur once or multiple times. In addition, we can use () to represent the order of conditions.

For exampleStore_InformationIf you select all materials whose Sales volume is higher than $1,000 or whose Sales volume is between $500 and $275,

Store_InformationTable

Store_Name Sales Txn_Date
Los Angeles 1500 05-Jan 1999
San Diego 250 07-Jan-1999
San Francisco 300 08-Jan 1999
Boston 700 08-Jan 1999

Let's get,

SELECT Store_Name
FROM Store_Information
WHERE Sales> 1000
OR (Sales <500 AND Sales> 275 );

Result:

Store_Name
Los Angeles
San Francisco


Linux test results:


Reprinted, please note: Xiao Liu

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.