adsense


Tuesday, 3 November 2015

SQL SELECT QUERY PAGE 14

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



SQL SELECT QUERY






SQL SELECT Query 


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 CUSTOMERS table having the following records: 
+----+----------+-----+-----------+----------+ 
| ID | NAME     | AGE | ADDRESS   | SALARY   | 
+----+----------+-----+-----------+----------+ 
|  1 | Ramakrishna  |  32 | Ahmedabad |  2000.00 | 
|  2 | Mdhu sudhan rao   |  25 | Delhi     |  1500.00 | 
|  3 | Sai  |  23 | Kota      |  2000.00 | 
|  4 | Kishor  |  25 | Mumbai    |  6500.00 | 
|  5 | Ranjith    |  27 | Bhopal    |  8500.00 | 
|  6 | Abhi    |  22 | MP        |  4500.00 | 
|  7 | Kumar     |  24 | Indore    | 10000.00 | 
+----+----------+-----+-----------+----------+ 
Following is an example, which would fetch ID, Name and Salary fields of the customers available in CUSTOMERS table: 
SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS; 
This would produce the following result: 
+----+----------+----------+ 
| ID | NAME     | SALARY   | 
CHAPTER 14
14 
+----+----------+----------+ 
|  1 | Ramakrishna  |  2000.00 | 
|  2 | Mdhu sudhan rao   |  1500.00 | 
|  3 | Sai  |  2000.00 | 
|  4 | Kishor  |  6500.00 | 
|  5 | Ranjith    |  8500.00 | 
|  6 | Abhi    |  4500.00 | 
|  7 | Kumar     | 10000.00 | 
+----+----------+----------+ 
If you want to fetch all the fields of CUSTOMERS table, then use the following query: 
SQL> SELECT * FROM CUSTOMERS; 
This would produce the following result: 
+----+----------+-----+-----------+----------+ 
| ID | NAME     | AGE | ADDRESS   | SALARY   | 
+----+----------+-----+-----------+----------+ 
|  1 | Ramakrishna  |  32 | Ahmedabad |  2000.00 | 
|  2 | Mdhu sudhan rao   |  25 | Delhi     |  1500.00 | 
|  3 | Sai  |  23 | Kota      |  2000.00 | 
|  4 | Kishor  |  25 | Mumbai    |  6500.00 | 
|  5 | Ranjith    |  27 | Bhopal    |  8500.00 | 
|  6 | Abhi    |  22 | MP        |  4500.00 | 
|  7 | Kumar     |  24 | Indore    | 10000.00 | 
+----+----------+-----+-----------+----------+ 
  
  


No comments: