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'