SQL SELECT Statement is used to fetch the data from a database table which returns data in the form of result table. These result tables are called result-sets.
Syntax: The basic syntax of SELECT statement is as follows:
SELECT column1, column2, columnN FROM table_name;
Here, column1, column2…are the fields of a table whose values you want to fetch. If you want to fetch all the fields available in the field, then you can use the following syntax:
SELECT * FROM table_name;
Example: Consider the EMP table having the following records:
SELECT * FROM EMP;
ENAME | DNAME | JOB | EMPNO | HIREDATE | LOC |
ADAMS | RESEARCH | CLERK | 7876 | 23-MAY-87 | DALLAS |
ALLEN | SALES | SALESMAN | 7499 | 20-FEB-81 | CHICAGO |
BLAKE | SALES | MANAGER | 7698 | 01-MAY-81 | CHICAGO |
CLARK | ACCOUNTING | MANAGER | 7782 | 09-JUN-81 | NEW YORK |
FORD | RESEARCH | ANALYST | 7902 | 03-DEC-81 | DALLAS |
JAMES | SALES | CLERK | 7900 | 03-DEC-81 | CHICAGO |
JONES | RESEARCH | MANAGER | 7566 | 02-APR-81 | DALLAS |
KING | ACCOUNTING | PRESIDENT | 7839 | 17-NOV-81 | NEW YORK |
MARTIN | SALES | SALESMAN | 7654 | 28-SEP-81 | CHICAGO |
MILLER | ACCOUNTING | CLERK | 7934 | 23-JAN-82 | NEW YORK |
SCOTT | RESEARCH | ANALYST | 7788 | 19-APR-87 | DALLAS |
SMITH | RESEARCH | CLERK | 7369 | 17-DEC-80 | DALLAS |
TURNER | SALES | SALESMAN | 7844 | 08-SEP-81 | CHICAGO |
WARD | SALES | SALESMAN | 7521 | 22-FEB-81 | CHICAGO |