Where Operator Usage :
In my last post I was talking about
Where clause and its operators.Now I am going to describe its usage with
Where clauses.
There are different types of usage operators with our requirement. I will give all the operators usage process with some example. It is used with SELECT,INSERT,UPDATE & DELETE statement.
I am giving it serially.
- Equal (=) :This operator is used when we comparing any value or characters with our required field. Like : SELECT * FROM table name
WHERE column name= value.

- Where clause with AND : It is used when we have multiple condition.Just like: SELECT column-names FROM table-name WHERE condition1 AND condition2

For Update : UPDATE table-name SET column-name = value WHERE condition1 AND condition2.
- Where clause with OR : It is used when any one value is acceptable, like: SELECT column-names FROM table-name WHERE condition1 OR condition2
For Update : UPDATE table-name SET column-name = value WHERE condition1 OR condition2.
For Delete : When we want to Delete some values depends on parameter the query looks like:
Delete column name from table name where column name = parameter

- Where Clause with BETWEEN :
- WHERE BETWEEN returns values that fall within a given range.
- WHERE BETWEEN is a shorthand for >= AND <=.
- BETWEEN operator is inclusive: begin and end values are included.
Statement like : SELECT column-names FROM table-name WHERE column-name BETWEEN value1 AND value2.
- Where IN clause :
- WHERE IN returns values that matches values in a list or sub query.
- WHERE IN is a shorthand for multiple OR conditions. Query Like : SELECT column-names FROM table-name WHERE column-name IN (values)
Where Like Statement :
- WHERE LIKE determines if a character string matches a pattern.
- Use WHERE LIKE when only a fragment of a text value is known.
- WHERE LIKE supports two wildcard match options: % and _.
Syntax like :
SELECT column-names FROM table-name WHERE column-name LIKE value.
Example : SELECT Id, ProductName, UnitPrice, Package FROM Product WHERE ProductName LIKE 'Ca%'
Greater Than(>) and Greater than Equal (>=) Operator : This operator used for comparing with condition.
Syntax like : SELECT * FROM table name WHERE column name> value;
SELECT * FROM table name WHERE column name>= value;
Less than(<) and Less than Equal: Same as like upper one.Just change the direction.
Comments
Post a Comment