From 5ed1684e93f447284872f6d2ba8c8da921639999 Mon Sep 17 00:00:00 2001 From: aditya singh rathore <142787780+Adez017@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:59:20 +0530 Subject: [PATCH 1/3] Update the-inequality-operator.md --- .../sql/SQL-basics/the-inequality-operator.md | 122 ++++++++++-------- 1 file changed, 68 insertions(+), 54 deletions(-) diff --git a/docs/sql/SQL-basics/the-inequality-operator.md b/docs/sql/SQL-basics/the-inequality-operator.md index 63dd8432..96190ebf 100644 --- a/docs/sql/SQL-basics/the-inequality-operator.md +++ b/docs/sql/SQL-basics/the-inequality-operator.md @@ -3,22 +3,22 @@ id: the-inequality-operator title: The Inequality Operator sidebar_label: The Inequality Operator sidebar_position: 4 -tags: [html, web-development, document-structure] -description: In this tutorial, you will learn about the structure of an HTML document and how to create a basic HTML document. +tags: [sql, database, queries, operators] +description: In this tutorial, you will learn about the inequality operator and comparison operators in SQL to filter data effectively. --- # ๐Ÿ“— The Inequality Operator -To check if a coloumns value is not equal to another we use the inequality operator. +The inequality operator (`<>` or `!=`) helps you find records that **don't match** a specific value. Think of it as asking "show me everything except this!" -For example, consider a table named `Friends`. Below is how a simple table might look: +Let's start with a simple example. Imagine you have a `students` table and want to find all students who are NOT in their first year: :::info -```sql title="Friends" +```sql title="Students" | name | year | major | |-------------|------|---------| @@ -30,7 +30,7 @@ For example, consider a table named `Friends`. Below is how a simple table might - ```sql title="Creating SQL Tables & db. " + ```sql title="Finding students not in year 1" SELECT * FROM students WHERE year <> 1; @@ -39,7 +39,7 @@ WHERE year <> 1; - + | name | year | major | | -------- | ---- | ------- | | Lin Wong | 3 | Biology | @@ -50,19 +50,19 @@ WHERE year <> 1; -### ๐Ÿ“˜ Practise Example +### ๐Ÿ“˜ Let's Practice Together - > To query data from a table, use the FROM clause followed by the table's name. + > Here's another way to look at it: the FROM clause tells SQL which table to look in, and WHERE tells it what to filter. -For example, consider a table named `Friends`. Below is how a simple table might look: +For example, consider a table named `students`. Let's see the same example again to reinforce the concept: :::info -```sql title="Friends" +```sql title="Students" | name | year | major | |-------------|------|---------| | Ava Smith | 1 | Biology | @@ -73,7 +73,7 @@ For example, consider a table named `Friends`. Below is how a simple table might - ```sql title="Creating SQL Tables. " + ```sql title="Selecting non-first-year students" SELECT * FROM students WHERE year <> 1; @@ -81,7 +81,7 @@ WHERE year <> 1; - + | name | year | major | |----------|------|---------| | Lin Wong | 3 | Biology | @@ -93,25 +93,33 @@ WHERE year <> 1; -:::tip -The Inequality sign is useful when we want to get all items that dont satisfy a criterion. -it checks the value are not equal. -It can apply to all types of numbers. +:::tip ๐Ÿ’ก Quick Tip +The inequality operator is your "everything except" tool! It's perfect when you want to exclude specific values from your results. -By following these best practices, +**What it works with:** +- Numbers: `age <> 25` (everyone except 25-year-olds) +- Text: `major <> 'Biology'` (all majors except Biology) +- Dates: `signup_date <> '2024-01-01'` (all dates except New Year's Day) + +Pro tip: Use this when you know what you DON'T want in your results! ::: -### ๐Ÿ”„ Comparison Operator. +### ๐Ÿ”„ More Powerful Comparisons + +**The Problem:** Sometimes you need more than just "equal" or "not equal." + +**Real-world scenario:** You're analyzing air quality data and want to find cities with low pollution levels (under 100 on the pollution index). -> Sometimes, comparison with = and are not felxible enoguh like when filtering by price of a grocery itesm -> We can use conditions to select items having a property les s than a threshold value like chocolate items with a price less than 2$ -> We can also use the numeric properties , it dont need to put in the quotes. -> the = sign check if the two values are equal. -We want to code a condition to select records from the pollution table where the pollution_index is less than 100. +> **Good to know:** +> - Numbers don't need quotes: `pollution_index < 100` โœ… +> - Text needs quotes: `city = 'Tokyo'` โœ… +> - The `<` symbol means "less than" - just like in math! + +Here's how to find cities with clean air (pollution index under 100): :::info -```sql title="friends" +```sql title="Pollution" | city | pollution_index | |----------|-----------------| | Delhi | 168 | @@ -123,7 +131,7 @@ We want to code a condition to select records from the pollution table where the - ```sql title="Creating SQL Tables. " + ```sql title="Finding cities with low pollution" SELECT * FROM pollution WHERE pollution_index < 100; @@ -131,7 +139,7 @@ WHERE pollution_index < 100; - + | city | pollution_index | |----------|-----------------| | Shanghai | 74 | @@ -143,15 +151,17 @@ WHERE pollution_index < 100; ::: -## ๐Ÿงน Selecting Unique Values with numeric +## ๐Ÿงน Including the Boundary Value + +**What if we want cities with "acceptable" pollution levels?** Let's say anything 122 or below is acceptable. -We want to code a condition to select records from the pollution table where the pollution_index is less than or equal to 122. +The `<=` operator means "less than or equal to" - it includes the exact value too! :::info -```sql title="Subscribers" +```sql title="Pollution" | city | pollution_index | |----------|-----------------| | Delhi | 168 | @@ -163,7 +173,7 @@ We want to code a condition to select records from the pollution table where the - ```sql title="Creating SQL Tables. " + ```sql title="Finding cities with moderate pollution" SELECT * FROM pollution WHERE pollution_index <= 122; @@ -171,7 +181,7 @@ WHERE pollution_index <= 122; - + | city | pollution_index | |----------|-----------------| | Milano | 122 | @@ -185,17 +195,19 @@ WHERE pollution_index <= 122; ::: -## ๐Ÿงน Filtering coloumns +## ๐ŸŽฏ Getting Only What You Need + +**Smart tip:** You don't always need all the data! Sometimes you only want specific columns to make your results cleaner and easier to read. -When using contions we dont have to select all coloumns with *, we can select only a couple like name and year. -> We dont have to select all colouns when filtering. +**Example:** Instead of seeing all student info, maybe you just want names and years. +> **Memory trick:** Think of `SELECT *` as "give me everything" and `SELECT name, year` as "just give me the basics" --- :::info -```sql title="Subscribers" +```sql title="Students" | name | year | major | |-------------|------|---------| | Ava Smith | 1 | Biology | @@ -206,19 +218,19 @@ When using contions we dont have to select all coloumns with *, we can select on - ```sql title="Creating SQL Tables. " -SELECT * + ```sql title="Just names and years of first-year students" +SELECT name, year FROM students WHERE year = 1; ``` - -| name | year | major | -| ----------- | ---- | ------- | -| Ava Smith | 1 | Biology | -| Luis Garcia | 1 | Physics | + +| name | year | +| ----------- | ---- | +| Ava Smith | 1 | +| Luis Garcia | 1 | @@ -229,20 +241,22 @@ WHERE year = 1; ::: -## โœ… What You have Learned +## ๐ŸŽ‰ What You've Mastered + +Great job! You've learned the essential skills for smart data filtering: -This module covers four essential topics in data selection: +**๐Ÿšซ The "Not Equal" Expert** +You can now use `<>` and `!=` to exclude specific values and find everything except what you don't want. -- **Rows and Columns** - Learn how to access specific rows and columns in a dataset or table, the building blocks of any query. +**๐Ÿ“Š The Comparison Pro** +You've mastered `<`, `>`, `<=`, and `>=` for finding records above, below, or within specific ranges. -- **Select Data** - Understand the basic `SELECT` statement to retrieve data from a database. +**๐ŸŽฏ The Precision Selector** +You know how to pick just the columns you need instead of grabbing everything with `*`. -- **Select Multiple Columns** - Retrieve more than one column at a time in your queries to get the information you need all at once. +**๐Ÿ” The Smart Filterer** +You can combine `WHERE` clauses with any operator to create laser-focused queries that find exactly what you're looking for. -- **Select Distinct Values** - Use `DISTINCT` to eliminate duplicate records and identify unique entries within your dataset. +**Next up:** Try combining these operators with `AND` and `OR` to create even more powerful searches! ---- \ No newline at end of file +--- From 097cb5cec00cac8eebd165ccf747275cf01df664 Mon Sep 17 00:00:00 2001 From: aditya singh rathore Date: Thu, 21 Aug 2025 10:53:18 +0530 Subject: [PATCH 2/3] vercel fix --- src/pages/blogs/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/blogs/index.tsx b/src/pages/blogs/index.tsx index 90082445..f55a0f72 100644 --- a/src/pages/blogs/index.tsx +++ b/src/pages/blogs/index.tsx @@ -196,7 +196,7 @@ const BlogCard = ({ blog, index }) => { 5 min read - + Read Article โ†’ From 3652375519bd895a72e711770242a83bba1215f6 Mon Sep 17 00:00:00 2001 From: aditya singh rathore Date: Thu, 21 Aug 2025 13:12:05 +0530 Subject: [PATCH 3/3] revert back --- src/pages/blogs/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/blogs/index.tsx b/src/pages/blogs/index.tsx index f55a0f72..90082445 100644 --- a/src/pages/blogs/index.tsx +++ b/src/pages/blogs/index.tsx @@ -196,7 +196,7 @@ const BlogCard = ({ blog, index }) => { 5 min read - + Read Article โ†’