SELECT Statement
In this page:
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
SELECT * FROM users;
Specific Columns Select करना
हर column retrieve करने के बजाय specific columns नाम देना उस data की मात्रा कम कर देता है जो MySQL को पढ़नी और transmit करनी है, जो wide tables या धीमे network links पर queries को measurably तेज़ करता है।
उदाहरण: Selecting Specific Columns
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
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
SELECT VERSION();
SELECT के लिए Best Practices
production code में SELECT * से बचना एक widely recommended practice है: सिर्फ actually ज़रूरी columns fetch करना wasted memory, network traffic, और table के columns बाद में बदलने पर breakage से बचाता है।
उदाहरण: Best Practices for SELECT
-- Avoid SELECT * in production; name only the columns you need
SELECT name, email FROM users;
- बड़ी tables पर
SELECT *इस्तेमाल करना जब सिर्फ कुछ columns चाहिए हों, जो unnecessary data transfer करता है। - एक column name misspell करना, जो एक
Unknown columnerror देता है। - बिना
ORDER BYके rows को एक specific order में उम्मीद करना।
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: