PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) (SQL WHERE क्लॉज: तुलनात्मक ऑपरेटर्स और सशर्त फ़िल्टरिंग) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: The SQL WHERE clause filters individual rows before grouping or projection using comparison operators (=, !=, <>, <, >, <=, >=) under SQL three-valued logic (TRUE, FALSE, UNKNOWN).
अध्याय सार: SQL WHERE क्लॉज तुलनात्मक ऑपरेटर्स (=, !=, <>, <, >, <=, >=) और थ्री-वैल्यूड लॉजिक (TRUE, FALSE, UNKNOWN) के आधार पर ग्रुपिंग या कॉलम चयन से पहले पंक्तियों (Rows) को फ़िल्टर करता है।
SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=): Detailed Notes & Architecture (SQL WHERE क्लॉज: तुलनात्मक ऑपरेटर्स और सशर्त फ़िल्टरिंग)
1. Logical Execution Order and Row-Level Predicate Filtering (तार्किक निष्पादन क्रम और पंक्ति-स्तरीय फ़िल्टरिंग)
[EN] In SQL's logical query processing pipeline, WHERE executes immediately after FROM and JOIN clauses—long before GROUP BY, HAVING, SELECT, and ORDER BY. Because WHERE evaluates row-by-row prior to the SELECT projection phase, column aliases created inside the SELECT list cannot normally be referenced inside WHERE (raising an unknown column error in MySQL, PostgreSQL, and Oracle). Furthermore, omitting WHERE in UPDATE or DELETE statements modifies or erases every row in the target table.
[HI] SQL क्वेरी के तार्किक निष्पादन क्रम में WHERE क्लॉज FROM और JOIN के ठीक बाद तथा GROUP BY, HAVING, SELECT और ORDER BY से पहले चलता है। चूँकि WHERE, SELECT से पहले निष्पादित होता है, इसलिए SELECT में बनाए गए कॉलम एलियास (Alias) का उपयोग सीधे WHERE में नहीं किया जा सकता। यदि UPDATE या DELETE में WHERE छोड़ दिया जाए, तो पूरी टेबल की सभी पंक्तियाँ बदल या मिट जाती हैं।
2. Equality (=) and Inequality (<> vs !=) Standards (समानता (=) तथा असमानता (<> बनाम !=) मानक)
[EN] SQL uses a single equals sign (=) for equality comparison rather than the double equals (==) common in C, Java, or Python. For inequality, <> is the official ANSI/ISO SQL standard operator supported across all relational databases, whereas != is a widely adopted C-style extension that older strict ISO-only engines reject. Both operators perform symmetric checks on numeric, date, and character domains without mutating table data.
[HI] SQL में समानता जांचने के लिए सिंगल '=' चिह्न उपयोग होता है (C या Python की तरह '==' नहीं)। असमानता के लिए '<>' आधिकारिक ANSI/ISO SQL मानक ऑपरेटर है जो हर डेटाबेस में चलता है, जबकि '!=' एक प्रचलित एक्सटेंशन है जिसे कुछ पुराने मानक-कठोर इंजन स्वीकार नहीं करते। दोनों ऑपरेटर संख्या, दिनांक और स्ट्रिंग डेटा की सुरक्षित तुलना करते हैं।
3. Relational Ordering Operators (<, >, <=, >=) Across Data Types (विभिन्न डेटा टाइप्स पर <, >, <=, >= का व्यवहार)
[EN] Ordering operators compare numbers strictly by arithmetic value and dates chronologically (earlier timestamps are smaller than later ones). On string columns (CHAR/VARCHAR), < and > follow the column's active Collation order—in binary ASCII collation, uppercase 'Z' (90) sorts before lowercase 'a' (97), while case-insensitive (_ci) collations treat 'Apple' and 'apple' identically. Remember that <= and >= are inclusive of boundary values, whereas < and > strictly exclude endpoints.
[HI] तुलना ऑपरेटर्स संख्याओं को गणितीय मान से तथा DATE/TIMESTAMP को कालानुक्रम से परखते हैं (पुरानी तारीख छोटी मानी जाती है)। स्ट्रिंग कॉलम में '<' और '>' सक्रिय Collation नियमों पर चलते हैं—बाइनरी ASCII में बड़ा 'Z' (90) छोटे 'a' (97) से छोटा होता है, जबकि case-insensitive कॉलेशन केस का अंतर नहीं मानते। ध्यान रहे <= और >= में सीमांत मान भी शामिल रहता है।
4. Three-Valued Logic (3VL) and NULL Comparison Traps (थ्री-वैल्यूड लॉजिक (3VL) और NULL तुलना की सावधानियाँ)
[EN] Unlike classical boolean logic, any SQL comparison involving NULL (such as WHERE Bonus = NULL or WHERE Bonus <> 500 when Bonus is NULL) evaluates to UNKNOWN rather than TRUE or FALSE. The WHERE clause retains ONLY rows evaluating strictly to TRUE and discards both FALSE and UNKNOWN rows. Consequently, WHERE Dept <> 'IT' silently drops rows where Dept is NULL; developers must test missing values with IS NULL / IS NOT NULL or ANSI null-safe IS NOT DISTINCT FROM.
[HI] सामान्य बूलियन लॉजिक के विपरीत, SQL में किसी भी मान की NULL से तुलना (जैसे Bonus = NULL या NULL <> 500) TRUE या FALSE के बजाय UNKNOWN परिणाम देती है। WHERE क्लॉज केवल उन्हीं पंक्तियों को रखता है जिनका परिणाम TRUE हो, और FALSE तथा UNKNOWN दोनों को बाहर कर देता है। इसलिए WHERE Dept <> 'IT' लिखने पर NULL विभाग वाली पंक्तियाँ भी छूट जाती हैं; NULL जांच के लिए IS NULL ही लिखना अनिवार्य है।
Syntax, Formula & Technical Example (SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=))
-- ANSI SQL filtering across numeric, string, and date columns
SELECT EmpID, Name, Dept, Salary
FROM Employees
WHERE Dept <> 'Intern'
AND Salary >= 35000
AND JoinDate < '2024-01-01';
-- Invalid in standard SQL (SELECT alias cannot be used in WHERE):
-- SELECT Salary * 12 AS Annual FROM Employees WHERE Annual > 500000;
SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) Quick Reference & Comparison Table
| Operator | Evaluation Rule & Standard | Exam Note & Edge Case |
|---|---|---|
| = (Equal To) | True if both sides share identical value; yields UNKNOWN with NULL | Single '=' in SQL (never '=='); WHERE col = NULL matches 0 rows |
| <> vs != (Not Equal) | <> is ANSI/ISO standard inequality; != is a vendor-supported alias | Prefer <> for portability; also drops NULL rows unless IS NULL used |
| < and <= (Less Than) | Compares numeric magnitude, earlier dates, or collation string order | <= includes exact boundary; 'Z' < 'a' under binary ASCII collation |
| > and >= (Greater Than) | Retains rows strictly above (>) or at-and-above (>=) threshold | WHERE keeps only TRUE results; FALSE and UNKNOWN are discarded |
SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) Top 20 Bilingual MCQs with Answers
Q1. In SQL's logical query execution order, when is the WHERE clause evaluated?
(SQL क्वेरी के तार्किक निष्पादन क्रम में WHERE क्लॉज कब मूल्यांकित होता है?)
(A) After HAVING and before GROUP BY
(B) After FROM/JOIN and before GROUP BY, HAVING, and SELECT
(C) After SELECT and just before ORDER BY
(D) Only after ORDER BY sorts the output
Correct Answer: (B)
[EN] SQL processes FROM -> JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY.
[HI] SQL में क्रम FROM -> JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT -> ORDER BY होता है।
Q2. Which inequality operator is guaranteed by the ANSI/ISO SQL standard across all RDBMS platforms?
(सभी RDBMS में ANSI/ISO SQL मानक द्वारा गारंटीकृत असमानता (Not Equal) ऑपरेटर कौन सा है?)
(A) ><
(B) =/=
(C) <>
(D) !=
Correct Answer: (C)
[EN] <> is the official ANSI/ISO SQL standard; != is a widely supported C-like extension.
[HI] <> आधिकारिक ANSI/ISO SQL मानक है, जबकि != एक प्रचलित एक्सटेंशन है।
Q3. Why does `SELECT Salary * 12 AS AnnualSal FROM Emp WHERE AnnualSal > 600000` fail in standard SQL?
(मानक SQL में `SELECT Salary * 12 AS AnnualSal FROM Emp WHERE AnnualSal > 600000` क्वेरी त्रुटि क्यों देती है?)
(A) Because arithmetic expressions are forbidden inside SELECT
(B) Because '>' cannot compare numbers larger than 65535
(C) Because WHERE executes before SELECT, so the alias AnnualSal does not exist yet during WHERE evaluation
(D) Because WHERE only accepts string comparisons
Correct Answer: (C)
[EN] Column aliases assigned in SELECT become visible only to later clauses like ORDER BY.
[HI] WHERE क्लॉज SELECT से पहले चलता है, इसलिए WHERE के समय SELECT में बना एलियास उपलब्ध नहीं होता।
Q4. Table Staff has 6 rows with Dept values ('IT', 'HR', NULL, 'IT', 'Sales', NULL). How many rows does `SELECT * FROM Staff WHERE Dept <> 'IT'` return?
(Staff टेबल की 6 पंक्तियों में Dept मान ('IT', 'HR', NULL, 'IT', 'Sales', NULL) हैं। `WHERE Dept <> 'IT'` कितनी पंक्तियाँ लौटाएगा?)
(A) 4 rows ('HR', 'Sales', and both NULLs)
(B) 0 rows
(C) 2 rows ('HR' and 'Sales')
(D) 6 rows
Correct Answer: (C)
[EN] For both NULL rows, NULL <> 'IT' yields UNKNOWN, and WHERE keeps only rows evaluating to TRUE.
[HI] NULL <> 'IT' का परिणाम UNKNOWN आता है और WHERE केवल TRUE पंक्तियाँ रखता है, अतः केवल HR और Sales (2 पंक्तियाँ) मिलेंगी।
Q5. In SQL three-valued logic (3VL), what does `WHERE Commission = NULL` evaluate to for rows where Commission actually is NULL?
(SQL थ्री-वैल्यूड लॉजिक (3VL) में जहां Commission का मान NULL हो, वहां `WHERE Commission = NULL` का परिणाम क्या होगा?)
(A) FALSE (throws a division error)
(B) Automatically converts NULL to 0
(C) TRUE (so the row is selected)
(D) UNKNOWN (so the row is NOT selected)
Correct Answer: (D)
[EN] Comparing anything to NULL with '=' produces UNKNOWN; always write WHERE Commission IS NULL.
[HI] NULL की '=' से तुलना करने पर UNKNOWN आता है और कोई भी पंक्ति नहीं चुनी जाती; इसके लिए IS NULL लिखना चाहिए।
Q6. What happens when an UPDATE or DELETE statement is executed without a WHERE clause?
(यदि UPDATE या DELETE कमांड को बिना WHERE क्लॉज के चलाया जाए तो क्या होगा?)
(A) Only rows containing NULL are modified
(B) SQL refuses to run and throws SyntaxError
(C) Every single row in the entire table is updated or deleted
(D) Only the first row is updated or deleted
Correct Answer: (C)
[EN] Without WHERE filtering, DML UPDATE/DELETE applies unconditionally to all rows of the table.
[HI] WHERE के बिना UPDATE या DELETE पूरी टेबल की सभी पंक्तियों पर लागू हो जाता है।
Q7. Why is `SELECT * FROM Orders WHERE TotalAmount >= 1000` preferred over `WHERE TotalAmount > 1000` when ₹1000 orders must qualify?
(यदि ₹1000 के ऑर्डर को भी शामिल करना हो तो `>` के बजाय `>=` क्यों आवश्यक है?)
(A) '>' works only on strings while '>=' works on integers
(B) '>=' is inclusive of the boundary value 1000, whereas '>' strictly excludes 1000
(C) '>=' automatically sorts results ascending
(D) '>=' skips NULL checks faster
Correct Answer: (B)
[EN] Strict inequality '>' rejects exact matches (1000 > 1000 is FALSE), while '>=' retains them.
[HI] '>' में 1000 > 1000 असत्य हो जाता है, जबकि '>=' सीमांत मान 1000 को भी शामिल करता है।
Q8. Which SQL statement can filter individual rows BEFORE an aggregate function runs, and which cannot contain aggregate functions directly?
(कौन सा क्लॉज एग्रीगेशन से पहले पंक्तियाँ फ़िल्टर करता है और सीधे एग्रीगेट फंक्शन (जैसे AVG) नहीं रख सकता?)
(A) GROUP BY clause
(B) ORDER BY clause
(C) HAVING clause
(D) WHERE clause
Correct Answer: (D)
[EN] WHERE filters raw tuples prior to grouping and strictly prohibits aggregate expressions like WHERE AVG(Marks) > 50.
[HI] WHERE ग्रुपिंग से पहले पंक्तियों को छांटता है और इसमें सीधे COUNT() या AVG() जैसे एग्रीगेट फंक्शन नहीं लिखे जा सकते।
Q9. Under a standard binary ASCII collation, how does `'Apple' < 'banana'` evaluate in a SQL WHERE clause?
(बाइनरी ASCII कॉलेशन में SQL WHERE क्लॉज में `'Apple' < 'banana'` का परिणाम क्या होगा?)
(A) SyntaxError: cannot compare strings with '<'
(B) UNKNOWN
(C) TRUE (ASCII 'A' = 65 is smaller than 'b' = 98)
(D) FALSE
Correct Answer: (C)
[EN] Binary/ASCII ordering compares code points left-to-right; uppercase letters (65–90) precede lowercase letters (97–122).
[HI] बाइनरी ASCII कॉलेशन में बड़े अक्षर 'A' (65) का मान छोटे 'b' (98) से कम होता है, अतः परिणाम TRUE होगा।
Q10. What is the result of `WHERE Marks >= 50 AND Marks <= 80` if Marks is 50?
(यदि Marks का मान 50 है, तो `WHERE Marks >= 50 AND Marks <= 80` का परिणाम क्या होगा?)
(A) UNKNOWN
(B) Compilation Error
(C) FALSE (row is excluded)
(D) TRUE (row is included)
Correct Answer: (D)
[EN] 50 >= 50 is TRUE and 50 <= 80 is TRUE; TRUE AND TRUE yields TRUE.
[HI] 50 >= 50 और 50 <= 80 दोनों TRUE हैं, इसलिए यह पंक्ति परिणाम में शामिल होगी।
Q11. In SQL date filtering, which condition selects transactions recorded strictly before the year 2025?
(दिनांक फ़िल्टरिंग में कौन सी शर्त केवल 2025 से ठीक पहले के लेन-देन (Transactions) चुनेगी?)
(A) WHERE TxnDate <= '2025-01-01'
(B) WHERE TxnDate > '2025-01-01'
(C) WHERE TxnDate < '2025-01-01'
(D) WHERE TxnDate = '2025-01-01'
Correct Answer: (C)
[EN] Using '< 2025-01-01' excludes January 1, 2025 and all later dates chronologically.
[HI] '< 2025-01-01' लिखने से 1 जनवरी 2025 और उसके बाद की सभी तारीखें बाहर हो जाती हैं।
Q12. Which non-standard equality operator in MySQL performs a NULL-safe comparison returning TRUE for `NULL <=> NULL`?
(MySQL में कौन सा विशेष ऑपरेटर `NULL <=> NULL` की तुलना करने पर UNKNOWN के बजाय TRUE लौटाता है?)
(A) ===
(B) <=> (Spaceship / NULL-safe equal)
(C) !=
(D) <>
Correct Answer: (B)
[EN] MySQL's <=> (equivalent to ANSI IS NOT DISTINCT FROM) returns 1 when both operands are NULL and 0 when only one is NULL.
[HI] MySQL का '<=>' (ANSI में IS NOT DISTINCT FROM) दोनों ओर NULL होने पर भी TRUE (1) लौटाता है।
Q13. Why might `WHERE Salary * 1.0 > 50000` run slower than `WHERE Salary > 50000` on a million-row table with an index on Salary?
(लाखों पंक्तियों वाली टेबल में Salary पर इंडेक्स होने पर भी `WHERE Salary * 1.0 > 50000` धीमा क्यों चल सकता है?)
(A) Wrapping the indexed column inside an arithmetic expression breaks SARGability, forcing a full scan instead of an index seek
(B) Because WHERE does not allow decimal literals
(C) Because multiplying by 1.0 changes integer to string
(D) Because SQL deletes the index automatically
Correct Answer: (A)
[EN] Keeping indexed columns bare on one side of comparison operators allows the optimizer to seek the B-tree index.
[HI] इंडेक्स वाले कॉलम पर गणितीय फंक्शन लगाने से इंडेक्स का सीधा उपयोग (SARGability) रुक जाता है और पूरी टेबल स्कैन करनी पड़ती है।
Q14. How do you test chained range limits `18 <= Age <= 60` correctly in ANSI SQL?
(ANSI SQL में `18 <= Age <= 60` जैसी शर्त लिखने का सही सिंटैक्स क्या है?)
(A) WHERE Age >= 18 AND Age <= 60
(B) WHERE 18 <= Age <= 60
(C) WHERE Age >= 18, <= 60
(D) WHERE Age == 18..60
Correct Answer: (A)
[EN] SQL does not support Python-style chained comparison operators; predicates must be joined explicitly with AND (or BETWEEN).
[HI] SQL में एक साथ दो तुलना चिह्न (18 <= Age <= 60) नहीं चलते; इन्हें AND से जोड़कर लिखना होता है।
Q15. What are the three possible truth values returned by SQL comparison predicates?
(SQL में तुलनात्मक शर्तें कुल कितने संभावित तार्किक परिणाम दे सकती हैं?)
(A) TRUE, FALSE, and UNKNOWN
(B) 0, 1, and -1
(C) TRUE and FALSE only
(D) YES, NO, and ERROR
Correct Answer: (A)
[EN] SQL implements Three-Valued Logic (3VL) specifically to accommodate missing/NULL values.
[HI] NULL मानों को संभालने के लिए SQL में 3-वैल्यूड लॉजिक (TRUE, FALSE, UNKNOWN) होता है।
Q16. Which statement is NOT true about the SQL WHERE clause?
(SQL WHERE क्लॉज के बारे में निम्नलिखित में से कौन सा कथन असत्य (NOT true) है?)
(A) WHERE comparison '=' never matches NULL
(B) WHERE runs before GROUP BY and HAVING
(C) WHERE can be used in SELECT, UPDATE, and DELETE statements
(D) WHERE retains rows whose condition evaluates to UNKNOWN
Correct Answer: (D)
[EN] WHERE strictly drops rows that evaluate to FALSE or UNKNOWN; only TRUE rows survive.
[HI] WHERE केवल TRUE परिणाम वाली पंक्तियों को रखता है; UNKNOWN वाली पंक्तियाँ छंट जाती हैं।
Q17. Within SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=), which operator directly maps to: "True if both sides share identical value; yields UNKNOWN with NULL"?
(SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) में कौन सा Operator सीधे "True if both sides share identical value; yields UNKNOWN with NULL" से संबंधित है?)
(A) > and >= (Greater Than)
(B) <> vs != (Not Equal)
(C) = (Equal To)
(D) < and <= (Less Than)
Correct Answer: (C)
[EN] In SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=), '= (Equal To)' handles 'True if both sides share identical value; yields UNKNOWN with NULL' (Single '=' in SQL (never '=='); WHERE col = NULL matches 0 rows).
[HI] SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) में '= (Equal To)' का कार्य/विवरण 'True if both sides share identical value; yields UNKNOWN with NULL' (Single '=' in SQL (never '=='); WHERE col = NULL matches 0 rows) है।
Q18. Which option accurately describes '<> vs != (Not Equal)' in SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=)?
(SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) के संदर्भ में '<> vs != (Not Equal)' की सही विशेषता कौन सी है?)
(A) True if both sides share identical value; yields UNKNOWN with NULL
(B) Retains rows strictly above (>) or at-and-above (>=) threshold
(C) <> is ANSI/ISO standard inequality; != is a vendor-supported alias
(D) Compares numeric magnitude, earlier dates, or collation string order
Correct Answer: (C)
[EN] '<> vs != (Not Equal)' provides '<> is ANSI/ISO standard inequality; != is a vendor-supported alias' — key point: Prefer <> for portability; also drops NULL rows unless IS NULL used.
[HI] '<> vs != (Not Equal)' का मुख्य विवरण '<> is ANSI/ISO standard inequality; != is a vendor-supported alias' है (Prefer <> for portability; also drops NULL rows unless IS NULL used)।
Q19. In SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=), identify the correct parameter for the specification: "Compares numeric magnitude, earlier dates, or collation string order".
(SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) में "Compares numeric magnitude, earlier dates, or collation string order" विवरण किस विकल्प के लिए सही है?)
(A) > and >= (Greater Than)
(B) <> vs != (Not Equal)
(C) < and <= (Less Than)
(D) = (Equal To)
Correct Answer: (C)
[EN] '< and <= (Less Than)' corresponds to 'Compares numeric magnitude, earlier dates, or collation string order' (<= includes exact boundary; 'Z' < 'a' under binary ASCII collation).
[HI] '< and <= (Less Than)' का संबंध 'Compares numeric magnitude, earlier dates, or collation string order' (<= includes exact boundary; 'Z' < 'a' under binary ASCII collation) से है।
Q20. Considering SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=), what key behavior defines '> and >= (Greater Than)'?
(SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) में '> and >= (Greater Than)' की मुख्य भूमिका या मान क्या है?)
(A) Retains rows strictly above (>) or at-and-above (>=) threshold
(B) Compares numeric magnitude, earlier dates, or collation string order
(C) True if both sides share identical value; yields UNKNOWN with NULL
(D) <> is ANSI/ISO standard inequality; != is a vendor-supported alias
Correct Answer: (A)
[EN] '> and >= (Greater Than)' represents 'Retains rows strictly above (>) or at-and-above (>=) threshold' (WHERE keeps only TRUE results; FALSE and UNKNOWN are discarded).
[HI] '> and >= (Greater Than)' का अर्थ/मान 'Retains rows strictly above (>) or at-and-above (>=) threshold' है (WHERE keeps only TRUE results; FALSE and UNKNOWN are discarded)।
SQL WHERE Clause and Filtering Operators (=, !=, <>, <, >, <=, >=) — Exam FAQs
Q1: Why can't I reference a SELECT column alias inside the WHERE clause?
मैं SELECT में बनाए गए कॉलम एलियास (AS) को WHERE क्लॉज में उपयोग क्यों नहीं कर पाता?
[EN] SQL evaluates FROM and WHERE before SELECT. At the moment WHERE inspects each row, aliases defined in SELECT have not yet been computed—repeat the expression in WHERE or wrap the query in a subquery/CTE.
[HI] SQL में WHERE क्लॉज SELECT से पहले चलता है, इसलिए WHERE के समय SELECT वाला एलियास बना ही नहीं होता। इसके लिए या तो पूरा फॉर्मूला दोहराएं या सबक्वेरी/CTE का उपयोग करें।
Q2: Why did `WHERE Status <> 'Closed'` omit rows where Status is NULL?
`WHERE Status <> 'Closed'` चलाने पर वे पंक्तियाँ क्यों गायब हो गईं जिनमें Status NULL था?
[EN] Under SQL three-valued logic, comparing NULL with <> returns UNKNOWN instead of TRUE, and WHERE keeps only TRUE rows. Add `OR Status IS NULL` to include them.
[HI] NULL <> 'Closed' का परिणाम TRUE नहीं बल्कि UNKNOWN आता है, और WHERE केवल TRUE पंक्तियाँ दिखाता है। इन्हें शामिल करने के लिए साथ में `OR Status IS NULL` जोड़ें।
Q3: Is there any functional difference between `<>` and `!=` in modern databases?
क्या आधुनिक डेटाबेस में `<>` और `!=` के कार्य में कोई अंतर है?
[EN] Functionally both behave identically in MySQL, PostgreSQL, SQL Server, and Oracle; however, `<>` is the strict ANSI/ISO SQL standard and is always safest for competitive exams and portable scripts.
[HI] आधुनिक डेटाबेस में दोनों एक समान काम करते हैं, परंतु `<>` आधिकारिक ANSI/ISO SQL मानक है—इसलिए परीक्षाओं और पोर्टेबल कोड में `<>` को ही प्राथमिकता दी जाती है।
Post a Comment
Post a Comment