Getting Started With SQL Function PATINDEX and Its Use Cases

[ad_1] Today, I will explain a SQL Server string function PATINDEX () used to return an integer value representing the starting position of the first occurrence of a pattern in a specified expression. This function will return zero if the pattern is not found in the specified expression. The syntax of this function is given … Read more

Understanding T-SQL Function SUBSTRING and Its Use Cases

[ad_1] This article will explain the T-SQL string function SUBSTRING() and its use cases. SQL Server offers various string functions to meet distinct business requirements. The SUBSTRING () function is one of them which is used to fetch part of a character, binary, text, or image expression in SQL Server. The syntax used for this … Read more

SQL Functions

SQL provides no. of inbuilt functions which perform calculations on groups of rows and return one value for the whole group. Commonly used SQL functions: 1. SQL AVG(): It is used to get the average value of a numeric column. Syntax: SELECT AVG(columnName) FROM tableName;   2. SQL COUNT(): It is used to get the … Read more

Categories SQL

SQL CARTESIAN JOIN

The CARTESIAN JOIN or CROSS JOIN return the data by joining the every row of one table to every row of another table i.e it returns the Cartesian product of two tables. Syntax: SELECT columnList FROM table1 t1, table1 t2; Example: SELECT * FROM PERSONS FULL OUTER JOIN ORDERS ON PERSONS.P_ID = ORDERS.PERSON_ID;SELECT * FROM … Read more

Categories SQL

SQL SELF JOIN

The SELF JOIN is used to join the table to itself that why it is known as SELF JOIN. Syntax: SELECT columnList FROM table1 t1, table1 t2 WHERE t1.commonColumn = t2. commonColumn; Example: SELECT emp1.EMP_NAME FROM EMPLOYEE emp1, EMPLOYEE emp2 WHERE emp1.AGE = emp2.AGE;SELECT emp1.EMP_NAME FROM EMPLOYEE emp1, EMPLOYEE emp2 WHERE emp1.AGE = emp2.AGE; Output: … Read more

Categories SQL

SQL FULL OUTER JOIN

The FULL OUTER JOIN returns the result of the combination of left and right outer joins. Syntax: SELECT columnList FROM table1 FULL OUTER JOIN table2 ON table1.columnName = table2.columnName; Example: SELECT P_ID, NAME, AMOUNT   FROM PERSONS   FULL OUTER JOIN ORDERS   ON PERSONS.P_ID = ORDERS.PERSON_ID;SELECT P_ID, NAME, AMOUNT FROM PERSONS FULL OUTER JOIN … Read more

Categories SQL

SQL RIGHT OUTER JOIN

The RIGHT OUTER JOIN returns the all records of right table and matching records of left table. When no match is found left table columns will be return with the null values. Syntax: SELECT columnList FROM table1 RIGHT OUTER JOIN table2 ON table1.columnName = table2.columnName; or SELECT columnList FROM table1 RIGHT JOIN table2 ON table1.columnName … Read more

Categories SQL

SQL LEFT OUTER JOIN

The LEFT OUTER JOIN returns the all records of left table and matching records of right table. When no match is found right table columns will be return with the null values. Syntax: SELECT columnList FROM table1 LEFT OUTER JOIN table2 ON table1.columnName = table2.columnName; or SELECT columnList FROM table1 LEFT JOIN table2 ON table1.columnName … Read more

Categories SQL

SQL INNER JOIN

The INNER JOIN returns the all records from the both tables for which the join condition is true. It is also known as EQUIJOIN. Syntax: SELECT columnList FROM table1 INNER JOIN table2 ON table1.columnName = table2.columnName; or SELECT columnList FROM table1 JOIN table2 ON table1.columnName = table2.columnName; Example: SELECT P_ID, NAME, AMOUNT   FROM PERSONS … Read more

Categories SQL