how to select row where Id is not equal to in SQL?


I want to select rows from a table where Id is not equal to 4, How to achieve it using SQL query?

Something like in C# .Where(a=>a.Id != 4).ToList() ?

Or in SQL like Select * Where Id != 4?

Thanks


Asked by:- Sam
0
: 8373 At:- 11/6/2017 11:42:27 AM
sql where negate select where id is not equal to







1 Answers
profileImage Answered by:- manish

Yes you can use not equal to SQL code, using negate in SQL 

SELECT *
FROM Table_name
WHERE Column_name <> Value;

//Example

SELECT OrderID, ProductID, Quantity
FROM order_details
WHERE Quantity <> 120;
 

Or you can use the query below

Select * FROM table_name WHERE Id NOT IN ( value )
1
At:- 11/7/2017 3:52:55 AM
thanks first solution worked for me, didn't tried NOT IN one 0
By : Sam - at :- 11/13/2017 11:37:28 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use