SQL where statement usage and instance tutorial

Source: Internet
Author: User

The most useful feature of SQL queries, because it allows you to selectively retrieve only rows of interest. The WHERE clause is used to specify the table, and only certain rows are displayed on the basis of where the criteria are described.

SELECT column_name
From derived_table
WHERE conditions

Instance One
SELECT Employeeidno
From employeestatisticstable
WHERE POSITION = ' Manager '

This will show all the administrator ID numbers. In general, text columns adhere to equals or not equal, and ensure that any text that appears in the declaration is surrounded by single quotes (').

SELECT Employeeidno, SALARY
From employeestatisticstable
WHERE POSITION = ' Manager ' and SALARY > 1000

You can combine any logical operator in the WHERE clause. In this case, the salary of all the managers returned by the query is a larger list of 1000 dollars.

Example Three

SELECT employeeaddresstable.address, Employeeaddresstable.lastname
From employeestatisticstable,employeeaddresstable
WHERE Employeeaddresstable.employeeidno = Employeestatisticstable.employeeidno
and employeestatisticstable.position = ' Staff '

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.