728x90 AdSpace

Trending

SELECT COMMAND in database

Click here for CREATE and INSERT commands.Once data has been inserted into a table, the next most logical operation wouldbe to view what has been inserted.The SELECT SQL verb is used to achieve this.SELECT command is used to retrieve rows selected from one or more tables.

SELECT COMMAND

There are so many ways to select the data form database.You can select all rows and columns or you can filter the table data to get more accurate result.

In order to view total data, the syntax is:-

SELECT columnname(S)/[*] FROM tablename;
* is wildcard character which is used to select all the rows.

Filtering the data table:-

 To get only selected columns and all the rows data use below syntax:
   
 select columnname1,columnname2,.. from tablename;

 To get all columns and only selected rows then make use of WHERE clause of select statement.
   SELECT columnnames FROM tablename
   WHERE condition;

condition: columnname=value;
you can use any relational operator instead of = operator.
eg:

SELECT * FROM emp
WHERE sal=2000;

 To get selected columns and selected row details.
SELECT columnname1,columnname2 FROM emp
WHERE job='MANAGER' AND
sal=3000;

 Eleminate duplicate values using distinct clause
SELECT [DISTINCT] columnnames FROM tablenames.
sorting data in a table
SELECT * FROM tablename
ORDER BY columnname(S) [sortorder];

Tips:-

We can use select statement to create a table
CREATE TABLE tablename(column(s))
as SELECT columnlist FROM tablename.

Inserting data into a table from anothertable
INSERT INTO tablename
SELECT columnlist FROM tablename
WHERE condition;

here we have mentioned above select statement only in the concept of JDBC .
SELECT COMMAND in database Reviewed by B AProgrammer on 11:18 Rating: 5 Click here for CREATE and INSERT commands.Once data has been inserted into a table, the next most logical operation wouldbe to view what has...

No comments: