A concise tutorial of SQL statements for Linux---and OR

Source: Internet
Author: User

On the previous page, we see where directives can be used to conditionally select data from a table. This condition may be simple (like the previous page example). may also be complex.

A complex condition is a connection of two or more simple conditions through and OR OR. There can be an infinite number of simple conditions in an SQL statement.

The syntax for complex conditions is as follows:

Select "Field name"
From "Table name"
WHERE "Simple Condition"
{[And|or] "simple condition"}+;

{}+ represents one or more occurrences within {}.}

What this means here is that the condition of and plus simple conditions and or plus simple conditions can occur one or more times. In addition, we can use () to represent the order of the conditions.

For example, if we want to select all the sales above $1,000 or sales between $ store_information and $275 in the table,

store_information Form

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

We'll break in,

SELECT Store_name
From Store_information
WHERE Sales > 1000
or (Sales < sales > 275);

Results:

Store_name
Los Angeles
San Francisco


Linux Real results:


Reprint please specify: Xiao Liu

A concise tutorial of SQL statements for Linux---and OR

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.