This tutorial shows you how to use SQL alias including column and table aliases to make your queries shorter and more understandable.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Vidyavathi | Female | 30 | Madurai |
2 | Varshini Kutty | Male | 32 | Hyderbhad |
3 | Hanumanthan | Female | 32 | Nasik |
4 | Devi Mai | Male | 25 | Kumbakonam |
This can be achieved in SQL. To do this, we specify that we want to change the table structure via the ALTER TABLE command.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Padmavathi | Male | 20 | Trichy |
2 | Vidyavathi | Female | 27 | Mumbai |
3 | Padmavathi | Female | 22 | Chennai |
4 | Dharan | Male | 25 | Nasik |
The AND operator can be used to join two or more conditions in the WHERE clause. Both sides of the AND condition must be true in order for the condition to be executed.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Simply SQL Server | 2005/03/14 8:43:4 | 17 | 2005/04/28 19:24:54 |
2 | Oracle PL/sql By Example | 2008/04/14 11:4:37 | 12 | 2008/05/16 16:11:54 |
3 | MySql Query Performance Tuning | 2007/01/18 3:16:21 | 16 | 2007/01/28 7:42:9 |
4 | PL/SQL the Programming Language of Oracle | 1997/08/21 14:56:49 | 18 | 1997/08/26 16:19:28 |
A short hint: In most cases auto-increment columns are used as Primary Key columns. In the SQL standard the junction of the two concepts is not mandatory.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL and Relational Database Design | 2006/07/24 4:36:53 | 10 | 2006/08/26 6:13:4 |
2 | Mastering Oracle SQL | 1996/03/21 23:56:31 | 19 | 1996/04/25 5:22:20 |
3 | Mastering Oracle SQL | 2002/01/20 8:38:47 | 7 | 2002/02/24 23:18:57 |
4 | Teach Yourself SQL in 10 Minutes | 2001/05/16 18:59:48 | 4 | 2001/06/20 12:51:16 |
This SQL tutorial explains how to use the SQL BETWEEN condition with syntax and examples.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | The Complete Guide to Oracle | 2005/03/22 18:23:28 | 1 | 2005/04/28 7:11:40 |
2 | Practical SQL | 2007/05/21 21:1:34 | 13 | 2007/06/24 17:58:31 |
3 | Jump Start MySQL | 2010/02/24 20:2:53 | 15 | 2010/02/26 17:45:28 |
4 | SQL Visual Quickstart | 2007/10/12 15:35:22 | 4 | 2007/11/27 13:7:22 |
SQL CREATE TABLE with constraint to exclude NULL value; SQL CREATE TABLE to check unique value; SQL CREATE TABLE to check.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Nirmala | Female | 33 | Chennai |
2 | Padmavathi | Female | 22 | Ramnad |
3 | Bala Murugan | Female | 23 | Hyderbhad |
4 | Harish Karthik | Female | 23 | Aruppukoottai |
This SQL Server tutorial explains how to use the CREATE TABLE statement in SQL Server (Transact-SQL) with syntax and examples.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | The Complete Guide to SQL Server | 2006/03/15 5:3:51 | 4 | 2006/04/25 18:57:26 |
2 | Oracle All-in-One For Dummies | 2005/06/11 8:56:30 | 15 | 2005/07/19 19:45:8 |
3 | Learing Sql Server T-Sql | 1996/03/14 15:48:25 | 15 | 1996/03/23 3:48:48 |
4 | SQL in Easy Steps | 1999/02/19 15:15:54 | 9 | 1999/03/22 10:53:16 |
The DEFAULT value clause in a data type specification indicates a default value ... MySQL handles the column according to the SQL mode in effect at the time:.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | MySQL Cookbook | 2011/05/17 21:34:14 | 11 | 2011/06/28 2:6:38 |
2 | Red Gate Guide to SQL Server | 2006/01/18 19:24:11 | 9 | 2006/02/26 3:42:25 |
3 | Securing Oracle | 2003/06/21 2:4:37 | 16 | 2003/06/26 18:5:40 |
4 | Access 2010 Pure Sql | 2007/10/26 8:13:21 | 17 | 2007/11/28 5:6:11 |
The SQL DELETE Query is used to delete the existing records from a table. You can use WHERE clause with DELETE query to delete selected rows, otherwise all rows will be deleted.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Nirmala | Male | 29 | Aruppukoottai |
2 | Harish Karthik | Male | 27 | Paramakudi |
3 | Pandurengan | Female | 21 | Chennai |
4 | Vidyavathi | Male | 33 | Paramakudi |
SQL SELECT DISTINCT with COUNT on ROWS or on one columns. ... SQL Keywords ... SELECT DISTINCT eliminates duplicate records from the results.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Troubleshooting SQL Server | 1995/05/18 18:52:2 | 16 | 1995/06/26 2:40:10 |
2 | Pro SQL Azure | 2004/03/15 16:17:4 | 12 | 2004/04/17 7:18:37 |
3 | Oracle Interview Questions | 2005/09/22 15:42:46 | 6 | 2005/10/26 5:21:15 |
4 | Pro Full-text Search In SQL Server | 2000/09/18 12:26:26 | 7 | 2000/10/27 16:58:25 |
This tutorial introduces you to MySQL foreign key and shows you step by step how to create.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Hanumanthan | Female | 31 | Kumbakonam |
2 | Devi Mai | Female | 30 | Pune |
3 | Hanumanthan | Female | 22 | Hyderbhad |
4 | Dharan | Male | 31 | Mumbai |
SQL Full Join (Full Outer Join) always contains all records of left table (Table A) and right table (Table B) even of join condition does not find any matching records.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Oracle Query Performance Tuning | 1996/05/26 5:32:25 | 19 | 1996/06/28 13:27:54 |
2 | From Access To SQL Server | 2003/05/22 3:14:59 | 14 | 2003/06/25 8:5:14 |
3 | The Complete Guide to SQL Server | 1995/09/24 9:23:14 | 15 | 1995/10/27 23:15:41 |
4 | A Visual Introduction To Sql | 2001/07/14 8:10:58 | 14 | 2001/07/25 19:29:52 |
The GROUP BY clause will gather all of the rows together that contain data in the specified column(s) and will allow aggregate functions to be performed on the grouped data.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | The Complete Guide to Oracle | 2001/07/11 20:40:33 | 8 | 2001/08/21 13:12:42 |
2 | Natural language Query To SQL | 2011/10/24 4:46:30 | 19 | 2011/10/27 2:11:40 |
3 | Easy Oracle PL/SQL Programming | 2010/04/13 4:55:49 | 8 | 2010/05/20 9:43:6 |
4 | Access 2010 Pure Sql | 2005/10/11 3:53:28 | 9 | 2005/10/22 11:53:4 |
The SQL HAVING clause is used in combination with the GROUP BY clause to restrict the groups of returned rows to only those whose the condition is TRUE.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Vinoth Kumar | Male | 34 | Aruppukoottai |
2 | Varshini Kutty | Female | 23 | Madurai |
3 | Padmavathi | Female | 28 | Bangalore |
4 | Padmavathi | Female | 33 | Trichy |
In SQL, there are two uses of the IN keyword, and this tutorial explain the one that is related to sql or operator.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Oracle Plsql Programming Fundamentals | 2006/04/23 12:45:56 | 3 | 2006/05/26 8:35:33 |
2 | Advanced SQL Functions in Oracle 10g | 2003/02/24 8:13:11 | 17 | 2003/02/28 19:44:10 |
3 | SQL and PL/SQL for Oracle 10g Black Book | 2004/03/11 6:1:23 | 1 | 2004/03/18 22:28:6 |
4 | Natural language Query To SQL | 1998/01/14 23:36:49 | 12 | 1998/02/16 9:4:59 |
how to use MySQL INNER JOIN clause to select data ... The MySQL INNER JOIN clause matches rows in one table with rows in other tables.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Varshini Kutty | Female | 33 | Nasik |
2 | Nirmala | Female | 27 | Nasik |
3 | Vinoth Kumar | Female | 22 | Trichy |
4 | Ranjani Mai | Male | 32 | Delhi |
SQL has the INSERT command that is used to store data into a table. The INSERT command creates a new row in the table.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Advanced SQL Functions in Oracle 10g | 2007/04/15 22:25:21 | 5 | 2007/05/18 19:22:19 |
2 | Expert SQL Server 2005 Development | 2002/03/15 18:10:8 | 19 | 2002/03/18 20:31:46 |
3 | SQL Server Database Internals | 2008/04/17 1:47:55 | 1 | 2008/04/25 8:32:26 |
4 | Professional Oracle | 2007/04/21 23:15:22 | 17 | 2007/04/25 6:50:53 |
A common task when using Transact-SQL (T-SQL) is to copy information from one table into another, possibly changing the data or its structure.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Sql Server Cookbook | 2006/09/14 13:12:54 | 15 | 2006/10/26 20:20:55 |
2 | SQL Server Data Transformation Services | 1995/05/15 16:14:10 | 14 | 1995/05/27 9:8:57 |
3 | Head First SQL | 1999/06/20 13:11:1 | 9 | 1999/07/25 1:59:57 |
4 | Transact SQL Cookbook | 1996/08/17 20:51:55 | 17 | 1996/08/19 6:6:58 |
The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2).
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Azaghu Varshith | Male | 28 | Aruppukoottai |
2 | Ramanathan | Female | 29 | Emaneshwaram |
3 | Dharan | Female | 30 | Chennai |
4 | Siva Kumar | Female | 30 | Kumbakonam |
The SQL LIKE operator is only applies on a field of types CHAR or VARCHAR to match a pattern using SQL wildcards.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | MySQL Cookbook | 2007/09/22 23:51:19 | 18 | 2007/10/27 8:7:40 |
2 | Programming With MySQL | 2011/07/22 2:10:7 | 15 | 2011/07/24 11:55:34 |
3 | Building A Data Warehouse In SQL Server | 2002/07/26 8:57:33 | 9 | 2002/08/28 10:3:17 |
4 | Oracle PL/sql By Example | 2005/01/24 20:30:28 | 4 | 2005/01/27 3:53:52 |
This tutorial introduces you to SQL NOT NULL constraint and shows you how to add the NOT NULL constraints to existing columns.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | PowerShell for SQL Server Essentials | 2009/03/12 19:53:1 | 15 | 2009/04/22 5:19:36 |
2 | Troubleshooting Oracle | 1998/03/13 4:53:56 | 5 | 1998/03/17 20:12:48 |
3 | Simply SQL Server | 2008/02/17 10:30:20 | 15 | 2008/02/21 5:25:17 |
4 | Access 2010 Pure Sql | 2010/01/26 18:22:9 | 5 | 2010/02/28 14:28:21 |
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in a descending order, you can use the DESC keyword.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Vidyavathi | Male | 27 | Emaneshwaram |
2 | Varshini Kutty | Female | 30 | Nasik |
3 | Padmavathi | Female | 30 | Paramakudi |
4 | Hanumanthan | Female | 28 | Pune |
A primary key is a field in a table which uniquely identifies each row/record in a database table. ... A primary key column cannot have NULL values.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | Teach Yourself SQL | 2010/03/20 6:33:24 | 18 | 2010/04/24 17:6:22 |
2 | Foundations Of Sql Server 2008 | 1997/04/20 14:49:53 | 6 | 1997/04/24 21:59:25 |
3 | Oracle Interview Questions | 2011/03/24 4:17:52 | 15 | 2011/04/27 14:29:37 |
4 | Oracle Plsql Programming Fundamentals | 2003/04/17 18:1:41 | 10 | 2003/04/28 10:16:15 |
SQL Right Join (Right Outer Join) always contains all records of right table even of join condition does not find any matching record in left table.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | A Visual Introduction To Sql | 2008/09/23 21:10:7 | 4 | 2008/10/26 8:40:12 |
2 | Access 2010 Pure Sql | 2009/09/19 22:3:59 | 18 | 2009/09/24 14:30:46 |
3 | SQL Server Query Performance Tuning | 2009/09/23 21:31:38 | 8 | 2009/09/26 5:9:57 |
4 | The Complete Guide to Oracle | 2007/05/22 20:48:32 | 14 | 2007/05/24 20:28:40 |
The result of a SELECT is zero or more rows of data where each row has a fixed number of columns. A SELECT statement does not make any changes to the database.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Varshini Kutty | Female | 28 | Pune |
2 | Vidyavathi | Female | 32 | Bangalore |
3 | Keshavan | Female | 20 | Mysore |
4 | Pandurengan | Male | 27 | Bangalore |
Limits the rows returned in a query result set to a specified number of rows or percentage of rows in SQL Server 2016. When TOP is used in conjunction with the other table.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Devi Mai | Male | 33 | Delhi |
2 | Chandra | Female | 27 | Ramnad |
3 | Pandurengan | Female | 25 | Delhi |
4 | Vidyavathi | Female | 26 | Hyderbhad |
UNION is used to combine the result from multiple SELECT statements into a single result set.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | The Database Language SQL | 1995/02/17 4:2:5 | 9 | 1995/03/27 3:2:39 |
2 | Programming with T-SQL for Beginners | 2011/03/19 1:34:43 | 11 | 2011/03/24 20:40:28 |
3 | Oracle Query Performance Tuning | 1995/01/24 13:59:18 | 9 | 1995/02/26 11:22:29 |
4 | SQL: The Complete Reference | 2006/01/22 14:8:28 | 17 | 2006/02/24 18:53:42 |
It is possible to put UNIQUE constraints on nullable columns but the SQL standard states that the constraint does not support duplicate values.
ID | BookName | OrderDate | Qty | DeliveryDate |
---|---|---|---|---|
1 | SQL Server Fundamentals | 1998/05/23 23:5:46 | 6 | 1998/06/27 23:14:34 |
2 | Getting Started With SQL | 1998/09/11 3:17:33 | 1 | 1998/09/23 6:56:43 |
3 | Securing SQL Server | 2001/05/15 14:32:5 | 16 | 2001/05/25 6:45:29 |
4 | Oracle PL/sql By Example | 2011/02/23 12:58:9 | 18 | 2011/02/26 6:28:10 |
For the multiple-table syntax, UPDATE updates rows in each table named in table-references that satisfy the conditions. Each matching row is updated once, even if it matches the conditions multiple times. For multiple-table syntax, ORDER BY and LIMIT cannot be used.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Nirmala | Male | 31 | Trichy |
2 | Bala Murugan | Male | 26 | Kumbakonam |
3 | Ranjani Mai | Female | 28 | Hyderbhad |
4 | Keshavan | Female | 24 | Chennai |
The SQL WHERE clause is used to specify a condition while fetching the data from single table or joining with multiple tables. If the given condition is satisfied then only it returns specific value from the table.
ID | EmpName | Gender | Age | City |
---|---|---|---|---|
1 | Rishi Keshan | Male | 25 | Ramnad |
2 | Padmavathi | Female | 20 | Pune |
3 | Chandra | Male | 32 | Hyderbhad |
4 | Padmavathi | Male | 24 | Chennai |