SQL Not Equal Operator introduction and examples

Today, We want to share with you not equal to in sql.In this post we will show you sql where multiple values, hear for sql notequal to multiple values we will give you demo and example for implement.In this post, we will learn about How To Run Sql Query In Command Prompt? with an example.

SQL Comparison Operators (Equal, NotEqual, Less than, Grater than)

We can have the following list if the comparison operators in SQL.

Operator

Description

=

Equals to

<>

NotEqual

!=

NotEqual

>

Greater than

>=

Greater than to equals to

<

Less than

<=

Less than or equals to

Difference between SQL NotEqual Operator <> and !=

CREATE TABLE dbo.Members
(MemberID         INT
 PRIMARY KEY IDENTITY(1, 1), 
 MemberName       VARCHAR(50), 
 MemberLaunchDate DATETIME2
);

Example 1: Get all member details except MemberID 1

Select * from dbo.members where MemberID <> 1

use != operator as well to get the same output.

Select * from dbo.members where MemberID!=1

Example 2: Get a list of all member except those launched in the Year 2009

Select * from dbo.members where Year(MemberLaunchDate) <>2009

Example 3: Get a list of all members excluding a specific member

Select * from dbo.members where Membername<>'Raghavjibhai'

Example 4: Specifying multiple conditions using SQL NotEqual operator

Select * from dbo.members where MemberID<>1 and MemberName<>'Viratkohali''

Example 5: SQL NotEqual operator and SQL Group By clause

Select Count(MemberLaunchDate) 
from dbo.Members
group by MemberLaunchDate
having Year(MemberLaunchDate) <>2009

Performance consideration of SQL NotEqual operator

Delete from members where MemberID>10

SQL Comparison Operators (Equal, NotEqual, Less than, Grater than)

  • SQL Equal (=) Operator
  • SQL NotEqual (!= or <>) Operator
  • SQL Greater Than (>) Operator
  • SQL Less Than (<) Operator
  • SQL Greater Than or Equal To (>=) Operator
  • SQL Less Than or Equal To (<=) Operator
  • SQL Not Less Than (!<) Operator
  • SQL Not Greater Than (!>) Operator
Read Also:  WordPress Security Tricks to Secure WordPress Website

create “MemberInformation” table

create table MemberInformation(memberid int, membername varchar(50),designation varchar(50),salary int,Location varchar(50))

 

insert into MemberInformation

values(1,'bhavika','software engineer',25000,'kalavad'),

(2,'jalpa','AEO',15000,'gondal'),

(3,'sejal','business analyst',50000,'surat'),

(4,'dhara','CA',75000,'rajkot'),

(5,'meera','Doctor',65000,'rajkot')

 
select * from MemberInformation

SQL Equal (=) Operator

SELECT * FROM MemberInformation WHERE memberid = 1

SQL NotEqual (!=) Operator

SELECT * FROM MemberInformation WHERE memberid != 1

SQL NotEqual (<>) Operator

SELECT * FROM MemberInformation WHERE memberid <> 1

SQL Greater Than (>) Operator

SELECT * FROM MemberInformation WHERE memberid > 2

SQL Less Than (<) Operator

SELECT * FROM MemberInformation WHERE memberid < 2

SQL Greater Than or Equal To (>=) Operator

SELECT * FROM MemberInformation WHERE memberid >= 2

SQL Less Than or Equal To (<=) Operator

SELECT * FROM MemberInformation WHERE memberid <= 2

SQL Not Less Than (!<) Operator

SELECT * FROM MemberInformation WHERE memberid !< 2

SQL Not Greater Than (!>) Operator

SELECT * FROM MemberInformation WHERE memberid !> 2

I hope you get an idea about not equal to in sql.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.