SQL LIKE operator

The LIKE operator is used in a WHERE clause to retrieve all records of a table whose specified column values match a specified pattern. The percent sign Syntax: SELECT * FROM tableName WHERE columnName LIKE pattern; Example: SELECT * FROM EMPLOYEE WHERE EMP_NAME LIKE ‘P%’;SELECT * FROM EMPLOYEE WHERE EMP_NAME LIKE ‘P%’; Output: EMP_ID EMP_NAME … Read more

Categories SQL

SQL UNION Operator

SQL UNION Operator. The UNION operator is used to combine the result sets of two or more SELECT statements. For UNION, every SELECT statement must have same number of columns with same data type and must be in same order. It will return the distinct values by removing the duplicate rows. Syntax: SELECT columnList FROM … Read more

Categories SQL

SQL OR Clause

The OR clause is also known as conjunctive operator and used to combine multiple conditions in SQL statement. Syntax: SELECT * FROM tableName WHERE [condition1] OR [condition2]…OR [conditionN]; In case of OR clause any one of the conditions separated by OR should be true. Example: SELECT * FROM EMPLOYEE WHERE SALARY > 40000 OR AGE … Read more

Categories SQL

SQL AND Clause

The AND clause is also known as conjunctive operator and used to combine multiple conditions in SQL statement. Syntax: SELECT * FROM tableName WHERE [condition1] AND [condition2]…AND [conditionN]; In case of AND clause all conditions should be true. Example: SELECT * FROM EMPLOYEE WHERE SALARY > 40000 AND AGE < 29;SELECT * FROM EMPLOYEE WHERE … Read more

Categories SQL

SQL WHERE Clause

The WHERE clause is used to add a condition to filter the records when we want to fetch the specific records instead of all records. Syntax: SELECT * FROM tableName WHERE [condition];  To specify a condition we can use any logical operator like >, <, =, LIKE, NOT etc. Example: SELECT * FROM EMPLOYEE WHERE … Read more

Categories SQL

SQL ALIAS Statement

The ALIAS statement is used to temporarily rename a table or column in a SQL statement. Syntax: SELECT columnName AS columnAliasName FROM tableName As tableAliasName; Example: SELECT EMP_NAME AS NAME FROM EMPLOYEE WHERE EMP_ID = 1;SELECT EMP_NAME AS NAME FROM EMPLOYEE WHERE EMP_ID = 1; Output: NAME ParbhjotNAME Parbhjot   Next Topic: SQL WHERE Clause … Read more

Categories SQL

SQL NOT BETWEEN Operator

The BETWEEN operator is used to select values within a range. The values can be numbers, dates or text. Syntax: SELECT * FROM tableName WHERE columnName NOT BETWEEN value1 AND value2; The value of the conditioned column should not be in the given range specified by NOT BETWEEN operator. Example: SELECT * FROM EMPLOYEE WHERE … Read more

Categories SQL

SQL BETWEEN Operator

The BETWEEN operator is used to select values within a range. The values can be numbers, dates or text. Syntax: SELECT * FROM tableName WHERE columnName BETWEEN value1 AND value2; The value of the conditioned column should be in the given range specified by BETWEEN operator. Example: SELECT * FROM EMPLOYEE WHERE SALARY BETWEEN 40000 … Read more

Categories SQL

SQL NOT IN Operator

The NOT IN operator is used to reduce the multiple or conditions by specifying the multiple values in a where clause. Syntax: SELECT * FROM tableName WHERE columnName NOT IN (value1,value2,… valueN); The value of the conditioned column should not be equal to the any of the specified values in the NOT IN operator. Example: … Read more

Categories SQL

SQL SELECT IN Operator

The IN operator is used to reduce the multiple or conditions by specifying the multiple values in a where clause. Syntax: SELECT * FROM tableName WHERE columnName IN (value1,value2,… valueN); The value of the conditioned column should be equal to the any one of the specified values in the IN operator. Example: SELECT * FROM … Read more

Categories SQL