Selecting the rows from the table:
--------------------------------------------
To retrieve the rows from the table select command is used.
Basic Syntax:
----------------
select * from < table_name>;
Ex:
-----
select * from student;
In the above command, * is a special character which is used to display all the information from the table.
To select specific columns:
-----------------------------------
select col1, col2... , coln from the <table_name>;
ex:
-----
select sno, sname from student;
select sname from student;
Selecting specific rows:
-------------------------------
Where clause is used to filter the rows from the table.
Syntax:
---------
select * from < table_name> where < condition >;
ex:
------
select * from student where marks > 70;
Combination of selecting specific row and selecting specific columns:
------------------------------------------------------------------------------------------
select sno from student where marks > 70;
Using Arithmetic operations with select command:
-----------------------------------------------------------------
Column alias is process of providing user definied column heading. select empno, ename , sal, sal* 12 annual_sal , deptno from emp; In the above query annual_sal is the column alias.
Using Distinct keyword:
-------------------------------
Distinct keyword is used to get the distinct ( unique ) values. Duplicates will be supressed.
ex:
------
select distinct deptno from emp;
Update command:
-----------------------
This command is used to change the data present in the table.
Syntax:
---------
Update < table_name> set <col_name> = < value> where < condition> ;