← Back to MySQL Course | Chapter 5: Inserting & Selecting Data | Lesson 3 of 6

SELECT Statement

SELECT किसी librarian से किसी table से certain columns लाने को कहने जैसा है। यह देखने का सबसे common तरीका है कि क्या store है।
Syntax
sql
SELECT column1, column2 FROM table_name;

SELECT * FROM table_name;

SELECT का Introduction

SELECT किसी table से rows retrieve करता है और सबसे frequently इस्तेमाल होने वाला single SQL statement है, किसी application के database के against perform किए जाने वाले लगभग हर read operation की foundation बनाते हुए।

उदाहरण: Introduction to SELECT

sql
SELECT * FROM users;

Specific Columns Select करना

हर column retrieve करने के बजाय specific columns नाम देना उस data की मात्रा कम कर देता है जो MySQL को पढ़नी और transmit करनी है, जो wide tables या धीमे network links पर queries को measurably तेज़ करता है।

उदाहरण: Selecting Specific Columns

sql
SELECT name, email FROM users;

SELECT में Basic Math

आप किसी SELECT की column list के अंदर सीधे arithmetic perform कर सकते हैं — जैसे price को quantity से multiply करना — table में stored कुछ भी बदले बिना on the fly derived values compute करने के लिए।

उदाहरण: Basic Math in SELECT

sql
SELECT name, price * quantity AS total FROM orders;

System Information Queries

SELECT बिना किसी table शामिल किए भी values return कर सकता है, जैसे server का current time या version, जो एक connection alive है यह sanity-check करने का एक handy तरीका है।

उदाहरण: System Information Queries

sql
SELECT VERSION();

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

SELECT के लिए Best Practices

production code में SELECT * से बचना एक widely recommended practice है: सिर्फ actually ज़रूरी columns fetch करना wasted memory, network traffic, और table के columns बाद में बदलने पर breakage से बचाता है।

उदाहरण: Best Practices for SELECT

sql
-- Avoid SELECT * in production; name only the columns you need
SELECT name, email FROM users;
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. बड़ी tables पर SELECT * इस्तेमाल करना जब सिर्फ कुछ columns चाहिए हों, जो unnecessary data transfer करता है।
  2. एक column name misspell करना, जो एक Unknown column error देता है।
  3. बिना ORDER BY के rows को एक specific order में उम्मीद करना।
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.