SQL where statement usage and example tutorial

Source: Internet
Author: User

SQL where statement usage and example tutorial

SQL where statement usage and example tutorial

The most useful feature of SQL query, because it allows you to selectively retrieve only the interest of rows. The WHERE clause is used to specify tables. Based on the fact that only some rows are displayed, it introduces the terms and conditions of this standard.

SELECT column_name
FROM derived_table
WHERE conditions

Instance 1
SELECT EMPLOYEEIDNO
FROM EMPLOYEESTATISTICSTABLE
Where position = 'manager'

This will display all administrator ID card numbers. In general, the text column is always equal to or not equal to, and make sure that any text is enclosed by single quotation marks (') in the Declaration (').

Select employeeidno, SALARY
FROM EMPLOYEESTATISTICSTABLE
Where position = 'manager' and salary> 1000

Any logical operators can be combined in the WHERE clause. Here, the salaries of all managers returned by the query are larger than $1000.

Instance 3

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.