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

What is Excel ? एक्सेल क्या है ?

Excel is a spreadsheet application which have rows and columns to organize data. We can easily organize and analysis data in excel. एक्सेल एक स्प्रेडशीट एप्लिकेशन है जिसमें डेटा व्यवस्थित करने के लिए पंक्तियां और कॉलम हैं। हम एक्सेल में आसानी से डेटा व्यवस्थित और विश्लेषण कर सकते हैं।

VBA Code to Clear Cells with Zero शून्य के साथ सेल को साफ़ करने के लिए VBA कोड

# VBA Code to Clear Cells with Zero:- To  clear cells with zero within a cell range using VBA , use a macro with the following statement structure: शून्य के साथ सेल को साफ़ करने के लिए VBA कोड For   Each   Cell  In   Range If   Cell.Value = myValue  Then   Cell.Clear Next   Cell VBA Statement Explanation Lines #1 and #3: For Each Cell In Range | Next Cell Item:  For Each… In… Next. VBA Construct:  For Each… Next statement. Description:  The For Each… Next statement repeats the statement within the loop (line #2) for each element (Cell) in the cell range (Range) you want to search for zeroes in. Item:  Cell. VBA Construct:  Element of the For Each… Next statement and object variable of the Range object data type. Description:  The Element of the For Each… Next statement is an object variable used to iterate through the elements (Cell) of the cell range (Range) you want to sear...

VBA Coding : For Sharing data by Email With Attachment using Excel data in other Place

' We have some data in Excel that we want to share by email with attachment हमारे पास Excel में कुछ डेटा हैं जिन्हें हम अनुलग्नक के साथ ईमेल द्वारा साझा करना चाहते हैं Sub For_GSTR3B_Report_Share() Dim sWorkbook1 As Workbook Dim wb As Workbook Dim objApp As Object  'For New Workbook Dim ws As Worksheet Dim savepath As String         'Delete all file from folder temp2         On Error Resume Next         Kill "C:\Users\PRAMOD.GARG\Desktop\pk_temp*.*"         On Error GoTo 0               On Error Resume Next         Set wb = Workbooks("Pkgarg_Control_Sheet_With_Gaurav_Coding.xlsm")         On Error GoTo 0         If Not wb Is Nothing Then         MsgBox "It's open"         wb.Activate         Worksheets("For_GSTR3B_Report_Share...