You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sql/SQL-basics/the-inequality-operator.md
+68-54Lines changed: 68 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,22 +3,22 @@ id: the-inequality-operator
3
3
title: The Inequality Operator
4
4
sidebar_label: The Inequality Operator
5
5
sidebar_position: 4
6
-
tags: [html, web-development, document-structure]
7
-
description: In this tutorial, you will learn about the structure of an HTML document and how to create a basic HTML document.
6
+
tags: [sql, database, queries, operators]
7
+
description: In this tutorial, you will learn about the inequality operator and comparison operators in SQL to filter data effectively.
8
8
---
9
9
10
10
11
11
# 📗 The Inequality Operator
12
-
To check if a coloumns value is not equal to another we use the inequality operator.
12
+
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!"
13
13
14
-
For example, consider a table named `Friends`. Below is how a simple table might look:
14
+
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:
15
15
16
16
17
17
18
18
:::info
19
19
<Tabs>
20
20
<TabItemvalue="SQL Table"label="SQL Table">
21
-
```sql title="Friends"
21
+
```sql title="Students"
22
22
23
23
| name | year | major |
24
24
|-------------|------|---------|
@@ -30,7 +30,7 @@ For example, consider a table named `Friends`. Below is how a simple table might
30
30
31
31
<TabItemvalue="SQL Code"label="SQL Code">
32
32
33
-
```sql title="Creating SQL Tables & db. "
33
+
```sql title="Finding students not in year 1"
34
34
SELECT*
35
35
FROM students
36
36
WHERE year <>1;
@@ -39,7 +39,7 @@ WHERE year <> 1;
39
39
40
40
</TabItem>
41
41
42
-
<TabItem value="how-git-works" label="Output">
42
+
<TabItem value="Output" label="Output">
43
43
| name | year | major |
44
44
| -------- | ---- | ------- |
45
45
| Lin Wong | 3 | Biology |
@@ -50,19 +50,19 @@ WHERE year <> 1;
50
50
51
51
52
52
53
-
### 📘 Practise Example
53
+
### 📘 Let's Practice Together
54
54
55
-
>To query data from a table, use the FROM clause followed by the table's name.
55
+
>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.
56
56
57
57
58
-
For example, consider a table named `Friends`. Below is how a simple table might look:
58
+
For example, consider a table named `students`. Let's see the same example again to reinforce the concept:
59
59
60
60
61
61
62
62
:::info
63
63
<Tabs>
64
64
<TabItem value="SQL Table" label="SQL Table">
65
-
```sql title="Friends"
65
+
```sql title="Students"
66
66
| name | year | major |
67
67
|-------------|------|---------|
68
68
| Ava Smith | 1 | Biology |
@@ -73,15 +73,15 @@ For example, consider a table named `Friends`. Below is how a simple table might
73
73
74
74
<TabItem value="SQL Code" label="SQL Code">
75
75
76
-
```sql title="Creating SQL Tables. "
76
+
```sql title="Selecting non-first-year students"
77
77
SELECT *
78
78
FROM students
79
79
WHERE year <> 1;
80
80
```
81
81
82
82
</TabItem>
83
83
84
-
<TabItem value="how-git-works" label="Output">
84
+
<TabItem value="Output" label="Output">
85
85
| name | year | major |
86
86
|----------|------|---------|
87
87
| Lin Wong | 3 | Biology |
@@ -93,25 +93,33 @@ WHERE year <> 1;
93
93
94
94
95
95
96
-
:::tip
97
-
The Inequality sign is useful when we want to get all items that dont satisfy a criterion.
98
-
it checks the value are not equal.
99
-
It can apply to all types of numbers.
96
+
:::tip 💡 Quick Tip
97
+
The inequality operator is your "everything except" tool! It's perfect when you want to exclude specific values from your results.
0 commit comments