SQL EQUAL,NOT EQUAL

Example Data Table : Orders (All of the below examples use this table as datasource)
Keyid OrderNo CustomerName SalePrice Quantity OrderDate
1 20101213095 John 3500 10 2010-12-13
2 20100620135 Jimmy 2509 22 2010-06-20
3 20100620392 Vincent 7200 5 2010-06-20
4 20100530006 John 9200 50 2010-05-30
5 20100515129 Vincent 100 50 2010-05-29
6 20100509059 John 2000 15 2010-05-09
7 20100503088 Alan 2200 17 2010-05-03


Example
To select rows that matches specified value
 
Sytax : SELECT * FROM table_name WHERE column_name = value
SQL
SELECT * FROM Orders WHERE CustomerName = 'John'

will output
Keyid OrderNo CustomerName SalePrice Quantity OrderDate
1 20101213095 John 3500 10 2010-12-13
4 20100530006 John 9200 50 2010-05-30
6 20100509059 John 2000 15 2010-05-09


Example
To select rows that doesn`t match specified value
 
Sytax : SELECT * FROM table_name WHERE column_name <> value
SQL
SELECT * FROM Orders WHERE CustomerName <> 'John'

will output
Keyid OrderNo CustomerName SalePrice Quantity OrderDate
2 20100620135 Jimmy 2509 22 2010-06-20
3 20100620392 Vincent 7200 5 2010-06-20
5 20100515129 Vincent 100 50 2010-05-29
7 20100503088 Alan 2200 17 2010-05-03
comments powered by Disqus