SQL > SQL Commands > Select
a) SELECT * FROM Users;
b) SELECT First_Name, Gender, Last_Name FROM Users;
c) SELECT First_Name, Last_Name Users;
d) SELECT All FROM Users;
असत्य। किसी तालिका में स्तंभों के क्रम का चयन कथन में स्तंभों के क्रम से कोई संबंध नहीं है।
सच। SQL कीवर्ड जैसे SELECT और FROM केस-संवेदी नहीं हैं।
The SELECT statement in SQL is used to retrieve data from a relational database.
SQL में SELECT स्टेटमेंट का उपयोग रिलेशनल डेटाबेस से डेटा को पुनः प्राप्त करने के लिए किया जाता है।
Syntax
| Number of Columns | SQL Syntax |
|---|---|
| 1 | SELECT "column_name" FROM "table_name"; |
| More Than 1 | SELECT "column_name1"[, "column_name2"] FROM "table_name"; |
| All | SELECT * FROM "table_name"; |
"table_name" is the name of the table where data is stored, and "column_name" is the name of the column containing the data to be retrieved.
"table_name" उस तालिका का नाम है जहां डेटा संग्रहीत किया जाता है, और "column_name" उस स्तंभ का नाम है जिसमें डेटा पुनर्प्राप्त किया जाना है।
To select more than one column, add a comma to the name of the previous column, and then add the column name. If you are selecting three columns, the syntax will be,
एक से अधिक कॉलम का चयन करने के लिए, पिछले कॉलम के नाम पर अल्पविराम जोड़ें और फिर कॉलम नाम जोड़ें। यदि आप तीन कॉलम का चयन कर रहे हैं, तो सिंटैक्स होगा,
SELECT "column_name1", "column_name2", "column_name3" FROM "table_name";
Note there is no comma after the last column selected.
ध्यान दें कि अंतिम कॉलम चयनित होने के बाद कोई अल्पविराम नहीं है।
Examples
We will provide examples for each of the following three use cases:
हम निम्नलिखित तीन उपयोग मामलों में से प्रत्येक के लिए उदाहरण प्रदान करेंगे:
- Retrieve one column
- Retrieve multiple columns
- Retrieve all columns
Let's use the following table to illustrate all three cases:
तीनों मामलों की व्याख्या करने के लिए निम्नलिखित तालिका का उपयोग करें:
Table Store_Information
| Store_Name | Sales | Txn_Date |
| Los Angeles | 1500 | Jan-05-1999 |
| San Diego | 250 | Jan-07-1999 |
| Los Angeles | 300 | Jan-08-1999 |
| Boston | 700 | Jan-08-1999 |
Example 1: Select one column
To select a single column, we specify the column name between SELECT and FROM as follows:
एकल कॉलम का चयन करने के लिए, हम निम्न और FROM के बीच कॉलम का नाम इस प्रकार से निर्दिष्ट करते हैं:
SELECT Store_Name FROM Store_Information;
Result:
| Store_Name |
| Los Angeles |
| San Diego |
| Los Angeles |
| Boston |
Example 2: Select multiple columns
We can use the SELECT statement to retrieve more than one column. To select Store_Name and Sales columns from Store_Information, we use the following SQL:
हम एक से अधिक कॉलम पुनः प्राप्त करने के लिए SELECT स्टेटमेंट का उपयोग कर सकते हैं। Store_Information से Store_Name और बिक्री कॉलम चुनने के लिए, हम निम्न SQL का उपयोग करते हैं:
SELECT Store_Name, Sales FROM Store_Information;
Result:
| Store_Name | Sales |
| Los Angeles | 1500 |
| San Diego | 250 |
| Los Angeles | 300 |
| Boston | 700 |
Example 3: Select all columns
There are two ways to select all columns from a table. The first is to list the column name of each column. The second, and the easier, way is to use the symbol *. For example, to select all columns from Store_Information, we issue the following SQL:
तालिका से सभी स्तंभों का चयन करने के दो तरीके हैं। सबसे पहले प्रत्येक कॉलम के कॉलम का नाम सूचीबद्ध करना है। दूसरा, और आसान तरीका, प्रतीक का उपयोग करना है *। उदाहरण के लिए, Store_Information से सभी कॉलम चुनने के लिए, हम निम्नलिखित SQL जारी करते हैं:
SELECT * FROM Store_Information;
Result:
| Store_Name | Sales | Txn_Date |
| Los Angeles | 1500 | Jan-05-1999 |
| San Diego | 250 | Jan-07-1999 |
| Los Angeles | 300 | Jan-08-1999 |
| Boston | 700 | Jan-08-1999 |
Exercises
For these exercises, assume we have a table called Users with the following columns:
इन अभ्यासों के लिए, मान लें कि हमारे पास निम्नलिखित स्तंभों के साथ उपयोगकर्ता नामक एक तालिका है:
Table Users
| Column Name |
| First_Name |
| Last_Name |
| Birth_Date |
| Gender |
| Date_Joined |
1. Which of the following SQL statement is incorrect? (There can be more than one answer)
1. निम्नलिखित में से कौन सा SQL कथन गलत है? (एक से अधिक उत्तर हो सकते हैं)
a) SELECT * FROM Users;
b) SELECT First_Name, Gender, Last_Name FROM Users;
c) SELECT First_Name, Last_Name Users;
d) SELECT All FROM Users;
2. (True Or False) In SQL, the order of the columns in a SELECT statement must be the same as the order of the columns in the underlying table. For example, in the table Users, you must select First_Name before Last_Name.
2. (सही या गलत) SQL में, SELECT स्टेटमेंट में कॉलम का क्रम अंतर्निहित टेबल में कॉलम के क्रम के समान होना चाहिए। उदाहरण के लिए, तालिका उपयोगकर्ताओं में, आपको Last_Name से पहले First_Name का चयन करना होगा।
3. (True Or False) The following two SQL statements are equivalent:
a) Select * From Users;
b) SELECT * FROM Users;
a) Select * From Users;
b) SELECT * FROM Users;
3. (सही या गलत) निम्नलिखित दो SQL कथन समतुल्य हैं:
क) उपयोगकर्ताओं से * का चयन करें;
बी) का चयन करें * उपयोगकर्ताओं से;
1. c), d).
2. False. The order of columns in a table has no relationship to the order of columns in a SELECT statement.
3. True. SQL keywords such as SELECT and FROM are not case-sensitive.
Comments
Post a Comment
Your advice or suggestions will be much appreciated and welcomed....