Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not Equal to query for SQL server

Tags:

sql

I was trying to execute a query which gets me all the info from Merchant table where PackageID is not equal to 21 or 22 or 23..

Select * from Merchant where PackageID NOT '22' Union Select * from Merchant where PackageID Not '21'

Thanks!!

like image 222
challengeAccepted Avatar asked Dec 28 '22 08:12

challengeAccepted


2 Answers

use PackageID NOT IN (21, 22, 23..)

 Select * from Merchant 
 where PackageID NOT IN (21, 22, 23)
like image 183
Michael Pakhantsov Avatar answered Jan 08 '23 12:01

Michael Pakhantsov


SELECT * FROM Merchant WHERE Packageid NOT IN ('21', '22', '23')
like image 36
faxi05 Avatar answered Jan 08 '23 11:01

faxi05