← Back to PostgreSQL Course | Chapter 2: Basic Queries | Lesson 2 of 7

WHERE Clause का उपयोग

WHERE सिर्फ वे rows रखता है जो एक condition satisfy करती हैं।

In this page:

  1. WHERE Clause
Syntax
sql
SELECT columns
FROM table_name
WHERE condition;

WHERE Clause

Conditions columns को values से compare करती हैं और true, false, या NULL evaluate होती हैं, और सिर्फ true rows return होती हैं। Text values single quotes इस्तेमाल करती हैं। WHERE grouping से पहले और column aliases available होने से पहले चलता है। AND, OR, और NOT से conditions combine करें।

Note: Strings के लिए single quotes और सिर्फ identifiers के लिए double quotes इस्तेमाल करें।

उदाहरण: WHERE clause

sql
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, city TEXT, age INTEGER);
INSERT INTO users VALUES (1, 'Ada', 'London', 36), (2, 'Bob', 'Oslo', 25), (3, 'Cy', 'Oslo', 41), (4, 'Di', 'Rome', 30);
SELECT * FROM users WHERE city = 'Oslo';
SELECT name FROM users WHERE age > 30;

-- Output:
-- id | name | city | age
-- 2 | Bob | Oslo | 25
-- 3 | Cy | Oslo | 41
-- name
-- Ada
-- Cy
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. string values के लिए double quotes इस्तेमाल करना
  2. = से NULL compare करना
  3. WHERE में aliases इस्तेमाल करना
चैप्टर सारांश
  • WHERE rows filter करता है
  • Text को single quotes चाहिए
  • NULL comparisons को IS NULL चाहिए
  • सिर्फ true rows return होती हैं
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 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.