Skip to main content

SQL > SQL Commands > Select

SQL > SQL Commands > Select
The SELECT statement in SQL is used to retrieve data from a relational database.

SQL में SELECT स्टेटमेंट का उपयोग रिलेशनल डेटाबेस से डेटा को पुनः प्राप्त करने के लिए किया जाता है।

Syntax

Number of ColumnsSQL Syntax
1SELECT "column_name" FROM "table_name";
More Than 1SELECT "column_name1"[, "column_name2"] FROM "table_name";
AllSELECT * 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_NameSalesTxn_Date
Los Angeles1500Jan-05-1999
San Diego250Jan-07-1999
Los Angeles300Jan-08-1999
Boston700Jan-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_NameSales
Los Angeles1500
San Diego250
Los Angeles300
Boston700

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_NameSalesTxn_Date
Los Angeles1500Jan-05-1999
San Diego250Jan-07-1999
Los Angeles300Jan-08-1999
Boston700Jan-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;

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.

सच। SQL कीवर्ड जैसे SELECT और FROM केस-संवेदी नहीं हैं।

Comments

Popular posts from this blog

Excel VBA Code For Clear Cell एक्सेल VBA कोड क्लियर सेल के लिए

# VBA Code to Clear Cell :- To  clear cells using VBA , use a statement with the following structure:- VBA का उपयोग :-  सेल  को साफ करने के लिए Cells.Clear VBA Statement Explanation Item:  Cells. VBA Construct:  Range object. Description:  Range object representing the cells you want to clear. You can usually return a Range object with constructs such as the Worksheet.Range, Worksheet.Cells (with Range.Item), Range.Offset, Range.Resize or Application.ActiveCell properties. If you explicitly declare an object variable to represent Cells, use the Range object data type. Item:  Clear. VBA Construct:  Range.Clear method. Description:  The Range.Clear method clears the Range object you specify (Cells). Range.Clear clears the entire Range object, including values, formulas and formatting. VBA स्टेटमेंट स्पष्टीकरण 1. आइटम: सेल। VBA निर्माण: रेंज ऑब्जेक्ट। विवरण: रेंज ऑब्जेक्ट उन कोश...

Insert Multiple Blank Row मल्टीपल ब्लैंक रो डालें

👍  If you ever need to insert multiple blank rows into your data, doing it manually could be very time consuming if you have a large data set. Here’s a quick way to do this by inserting a blank row into your data after every Nth record. यदि आपको कभी भी अपने डेटा में कई रिक्त पंक्तियों को सम्मिलित करने की आवश्यकता होती है, तो मैन्युअल रूप से ऐसा करने में बहुत समय लग सकता है यदि आपके पास एक बड़ा डेटा सेट है। हर Nth रिकॉर्ड के बाद आपके डेटा में एक रिक्त पंक्ति सम्मिलित करके ऐसा करने का एक त्वरित तरीका है। Add a column  to the right of your data. If the helper column is in  E1 , then add this formula into  E2  and copy it down to the end of the data. Change N to a number (5 if you want every 5th row etc…). =MOD(ROW(E2)-ROW($E$1)-1,N) Now  highlight  the whole column. Go to the  Home  tab in the ribbon. In the  Editing  section, press the  Find & Select  button. In the drop down menu, select  Find . You ...

Basic Excel Learn by Online ऑनलाइन द्वारा बेसिक एक्सेल जानें