Posts

Showing posts from July, 2018

SQL BETWEEN Operator - The Coding Shala

Image
Home >> Learn SQL >> SQL Between Operator SQL BETWEEN Operator The SQL 'BETWEEN' Operator is used to select values within the given range. These values can be numbers, texts or dates.  In SQL 'BETWEEN' Operator begin and end values are included. SQL BETWEEN Operator Syntax The basic syntax of SQL BETWEEN Operator is as follows -  SELECT column_name (s) FROM table_name WHERE column_name BETWEEN value1 AND value2; SQL BETWEEN Operator Example The following 'emp' table is used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24 Mumbai 50000 5 Smith 24 Pune 50000 6 Akshay 22 Pune 50000 7 Nikhil 24 Mumbai 43000 The

SQL IN Operator - The Coding Shala

Image
Home >> Learn SQL >> SQL IN Operator SQL IN Operator The SQL 'IN' Operator allows us to specify multiple values in where clause.  The SQL 'IN' Operator is useful when we have multiple 'or' condition.  The SQL 'IN' Operator is always used in 'Where' Clause. SQL IN Operator Syntax  The basic SQL IN operator syntax is as follows -  SELECT column_name (s) FROM table_name WHERE column_name IN (value1, value2, ...); OR  SELECT column_name (s) FROM table_name WHERE column_name IN ( SELECT STATEMENT ); SQL IN Operator Example  The following 'emp' table is used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24 Mumbai 50000 5 Smith 24 Pune

SQL Aliases - The Coding Shala

Image
Home >> Learn SQL >> SQL Aliases SQL Aliases SQL Aliases are used to give a temporary name to the table or a column.  By using Aliases we can change the name of columns or tables to make them more readable.  These changes are temporary, the actual table name does not change in the database.  The alias only exists for the duration of the query.  Aliases are two types -  column alias  and  table alias. SQL Aliases column syntax The basic SQL column Aliases syntax is as follows -  SELECT column_name AS alias_name FROM table_name ; SQL Aliases Table Syntax The basic SQL Table Aliases syntax is as follows -  SELECT column_name (s) FROM table_name AS alias_name; SQL Aliases Examples  The following 'emp' and  'Persons'  two tables are used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi

SQL Wildcard Operators - The Coding Shala

Image
Home >> Learn SQL >> SQL Wildcard Operator SQL Wildcard Operators The Wildcard operators are used with the SQL LIKE Clause. SQL LIKE is used in the WHERE clause to search for a specified pattern in the column .  There are two wildcards used in conjunction with the LIKE operator.  The percent sign(%) - represents zero, one or multiple characters.  The underscore(_) - represents a single character. These symbols can be used together. The following table shows some examples of the like operator with % and _ wildcards -  LIKE Operator Description where Name LIKE 'a%' Finds any values that start with "a" where Name LIKE '%a' Finds any values that end with "a" where Name LIKE '%a%' Finds any values that have "a" in any position where Name LIKE '_a%' Finds any values that have "a" in the sec

SQL LIKE Clause - The Coding Shala

Image
Home >> Learn SQL >> SQL Like Clause SQL LIKE Clause The SQL 'Like' is used in a WHERE Clause to search for a specific pattern in a column means SQL LIKE clause is used to compare a value to similar values using wildcard operators.  There are two wildcards used in conjunction with LIKE operator -   The percent sign(%) - represents zero, one or multiple characters.  The underscore(_) - represents a single character. These symbols can be used together. SQL LIKE Clause Syntax The basic SQL LIKE Clause syntax is as follows -  SELECT column1, column2, ... FROM table_name WHERE columnN LIKE pattern; SQL LIKE Clause Examples  The following 'emp' table will be used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24

SQL NOT Operator - The Coding Shala

Image
Home >> Learn SQL >> SQL NOT Operator SQL NOT Operator The SQL 'NOT' Operator displays records if the condition is not true. SQL NOT Operator Syntax The basic syntax of SQL NOT Operator is as follows -  SELECT column1, column2, ... FROM table_name WHERE NOT condition; SQL NOT Operator Examples  The following 'emp' table will be used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24 Mumbai 50000 5 Smith 24 Pune 50000 6 Akshay 22 Pune 50000 7 Nikhil 24 Mumbai 43000 The following query will return records if Name is not Akshay -  SQL >> select * from emp where NOT Name = 'Akshay' ; O

SQL OR Operator - The Coding Shala

Image
Home >> Learn SQL >> SQL OR Operator SQL OR Operator The SQL 'OR' Operator is used to filter out the records based on the one or more columns. The WHERE clause can be combined with the OR operator.  The SQL OR Operator displays records if any of the conditions that are separated by 'OR' are true. SQL OR Operator syntax The basic SQL OR operator syntax is as follows -  SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...; SQL OR Operator Examples  The following 'emp' will be used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24 Mumbai 50000 5 Smith 24 Pune 50000 6 Akshay 22 Pune 50000 7 Nikhi

SQL AND Operator - The Coding Shala

Image
Home >> Learn SQL >> SQL AND Operator SQL AND Operator The SQL 'AND' operator is used to filter out the records based on the one or more columns. The WHERE clause can be combined with AND operator.  The SQL AND Operator display records if all the conditions that are separated by 'AND' are true. SQL AND Operator syntax The basic SQL AND operator syntax is as follows -  SELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...; SQL AND Operator Examples  The following 'emp' table will be used for the examples -  Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24 Mumbai 50000 5 Smith 24 Pune 50000 6 Akshay 22 Pune 50000