डाउनलोड पी.डी.एफ. ई-बुक्स
SQL - SELECT Statement

SQL में ज्यादातर SELECT Statement का इस्तेमाल किया जाता है |

SELECT Statement का इस्तेमाल database के table से data पाने(retrieve) के लिए किया जाता है |

जो returned हुआ data होता है वो table जैसा होता है और उस returned हुए data को result-set कहा जाता है |


Syntax for SELECT Statement in SQL

For Single or Multiple Columns in SQL
SELECT column1,column2,..,columnN
FROM table_name;
For All Columns using * in SQL
SELECT *
FROM table_name;

Sample Table

+----+----------+-----------------+-------+------+
| id | Dealer   | Appliances      | Cost  | GST  |
+----+----------+-----------------+-------+------+
|  1 | Balaji   | T.V.            | 19000 | 3420 |
|  2 | Ravikant | Washing Machine | 15000 | 4200 |
|  3 | Electra  | Refrigerator    | 10000 | 2800 |
|  4 | K.K.     | Cooler          | 18000 | 5040 |
|  5 | Ganesh   | A.C.            | 35000 | 9800 |
|  6 | Rajaram  | Iron            |  1500 |  420 |
|  7 | Ravi     | Laptop          | 30000 | 8400 |
+----+----------+-----------------+-------+------+

Example For SELECT Statement with Single Column in SQL

Example पर Appliances इस table का सिर्फ Dealer ये column select किया गया है |

Source Code :
SELECT Dealer FROM Appliances;
Output :
+----------+
| Dealer   |
+----------+
| Balaji   |
| Ravikant |
| Electra  |
| K.K.     |
| Ganesh   |
| Rajaram  |
| Ravi     |
+----------+

Example For SELECT Statement with Multiple Columns in SQL

Example पर Appliances इस table के Dealer, Appliances और GST ये columns select किये गए है |

Source Code :
SELECT Dealer,Appliances,GST FROM Appliances;
Output :
+----------+-----------------+------+
| Dealer   | Appliances      | GST  |
+----------+-----------------+------+
| Balaji   | T.V.            | 3420 |
| Ravikant | Washing Machine | 4200 |
| Electra  | Refrigerator    | 2800 |
| K.K.     | Cooler          | 5040 |
| Ganesh   | A.C.            | 9800 |
| Rajaram  | Iron            |  420 |
| Ravi     | Laptop          | 8400 |
+----------+-----------------+------+

Example For SELECT Statement with All(*) Columns in SQL

Example पर Appliances इस table के सभी columns select किये गए है |

Source Code :
SELECT * FROM Appliances;
Output :
+----+----------+-----------------+-------+------+
| id | Dealer   | Appliances      | Cost  | GST  |
+----+----------+-----------------+-------+------+
|  1 | Balaji   | T.V.            | 19000 | 3420 |
|  2 | Ravikant | Washing Machine | 15000 | 4200 |
|  3 | Electra  | Refrigerator    | 10000 | 2800 |
|  4 | K.K.     | Cooler          | 18000 | 5040 |
|  5 | Ganesh   | A.C.            | 35000 | 9800 |
|  6 | Rajaram  | Iron            |  1500 |  420 |
|  7 | Ravi     | Laptop          | 30000 | 8400 |
+----+----------+-----------------+-------+------+