
Featured
-
How Regression Testing Detects Integral Errors In Business Processes
Humans are forever changing and evolving and so to
by kristina.rigina -
Get Display Banner Advertising Opportunity on FindNerd Platform
“Do you have a product or service that nee
by manoj.rawat -
Android O Released with Top 7 New Features for App Developers
Android was founded by Andy Rubin, Rich Miner, Nic
by sudhanshu.tripathi -
Top 5 Features That Make Laravel the Best PHP Framework for Development
Laravel is a free open source Web Framework of PHP
by abhishek.tiwari.458 -
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi
Tags
SQL Tutorial -> Sql Injection
<-- Chapter 20: SQL DELETE
Chapter 21
SQL INJECTION
SQL Injection is an injection attack wherein attacker is able to submit a database SQL command which is executed by a web application exposing back-end database. Attacker can add SQL ...
SQL Tutorial -> Sql Update
<-- Chapter 18: SQL INSERT
Chapter 19
SQL UPDATE
UPDATE statement is used to update existing table data in database table with the help of WHERE clause.WHERE clause tells which record is to be updated.
Lets see an example from the b...
SQL Tutorial -> Sql Insert
<-- Chapter 17: SQL ORDER BY
Chapter 18
SQL INSERT
INSERT INTO is the SQL Statement used to insert data in database table in the form of rows and columns.
Lets see an example from the below table "employees" :-
employee_id
...
SQL Tutorial -> Sql ORDER BY
<-- Chapter 16: SQL And & Or
Chapter 17
SQL ORDER BY
ORDER BY is the keyword used to sort the database table data by one or more columns. ORDER BY sort the Records in Ascending order by default. To sort the Record in Descending Ord...
SQL Tutorial > Sql <= Operator
<-- Chapter 14: SQL >= Operator
Chapter 15
SQL <= Operator
Lets see an example from the below table "employees" :-
employee_id
name
code
designation
salary
101
ABC
E-101
Engineer
12000
102
DEF
E-1...
SQL Tutorial > Sql >= Operator
<-- Chapter 13: SQL < Operator
Chapter 14
SQL >= Operator
Lets see an example from the below table "employees" :-
employee_id
name
code
designation
salary
101
ABC
E-101
Engineer
12000
102
DEF
E-10...
SQL Tutorial -> Sql < Operator
<-- Chapter 12: SQL > Operator
Chapter 13
SQL < Operator
Lets see an example from the below table "employees" :-
employee_id
name
code
designation
salary
101
ABC
E-101
Engineer
12000
102
DEF
E-102...
SQL Tutorial -> SQL BETWEEN Operator
<-- Chapter 10: SQL LIKE Operator
Chapter 11
SQL BETWEEN Operator
Lets see an example from the below table "employees" :-
employee_id
name
code
designation
salary
101
ABC
E-101
Engineer
12000
102
DEF
E-...
SQL Tutorial -> Sql LIKE Operator
<-- Chapter 9: SQL != Operator
Chapter 10
SQL LIKE Operator
Lets see an example from the below table "employees" :-
employee_id
name
code
designation
salary
101
ABC
E-101
Engineer
12000
102
DEF
E-102
D...
SQL Tutorial -> Sql NOT IN Operator
<-- Chapter 6: SQL IN Operator
Chapter 7
SQL NOT IN Operator
Lets see an example from the below table "employees" :-
employee_id
name
code
designation
salary
101
ABC
E-101
Engineer
12000
102
DEF
E-102
...
SQL Tutorial -> Sql Where
<-- Chapter 4: SQL Distinct
Chapter 5
SQL Where
SQL Where : SQL Where clause extract or filters those records which matches the specified condition. Syntax for Where clause is used below
SELECT *
FROM tablename
WHERE condition
...
SQL Tutorial -> Sql Distinct
<-- Chapter 3: SQL Select
Chapter 4
SQL District
SQL District : District is a keyword which is used to fetch unique column values from database table OR we can simply say that ignores the column duplicate values. Syntax for district ke...
ORDER BY Clause
Sorting the result using Order By clause:
ORDER BY clause is used to sort the data fetched using select statement either in ascending order or in descending. By default data fetched is sorted in ascending order.
Syntax:
Select columnname...
SQL Tutorial -> Sql Select
<-- Chapter 2: SQL Syntax
Chapter 3
SQL Select
SQL Select :
SELECT command describes that through which we can fetch data from MYSQL database tables OR we can say, It is used to retrieve/select data from MYSQL database.
SELECT comma...
SQL : How to get last N records based on ordering of a specific column in SQL Server ?
Sometimes we may be required to get the get last N records of a table in SQL server based on ordering on a specific column . In this post we will create a query to get the result. First let us create a table which we will use in our query.
CR...
SQL : How to reset identity seed after deletion of records in SQL server ?
By using the seed value for every new record Microsoft SQL Server's identity column generates sequential values. In this post we will learn how to reseed an identity column.
Following is the command to reset the identity property :
DBCC C...
SQL : How to get column names of a table in SQL Server ?
Often we may be required to get the names of all columns in a table in SQL server. In this post we will see the different options available in SQL server to fetch the column names.
1) We can use the below query to get the column names.
SELE...
SQL : How to Delete using INNER JOIN in SQL Server ?
In this post we will see how to use JOIN for deleting data from SQl server table. Let us first create tables which we will use for understanding the deletion process using JOINS.
-- Create table1
CREATE TABLE #Table1 (Col1 INT, Col2 VARCHAR(5...
SQL : How to check if a stored procedure exists before creation?
In this article we will learn how to check if a stored procedure exists before creating it. We can use the below script which will drop the proc if it exists and then recreate it.
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name...
SQl : How to replace a string in SQL server column ?
We know that the data can be changed inside a field by using update command.
In this article I will guide you to replace part of the data without changing the entire data of the field. For this we will use replace command to replace a part of t...
SQL Tutorial ->Introduction to SQL
Chapter 1
Introduction to SQL
Introduction to SQL : SQL stands for Structured Query Language or we can call it as "sequel" or "S-Q-L" . SQL is a query Language used to accessing and modifying information in a database.There are some common ...
Copying Data from one table into another
INSERT INTO SELECT statement:
INSERT INTO SELECT statement is used to copy data from existing table into another table.
Syntax-1:
INSERT INTO tablename2 SELECT * FROM tablename1;
Syntax-2
INSERT INTO tablename2 (columnname(s)) ...
SQL Tutorial -> Sql Syntax
<-- Chapter 1 Introduction to SQL
Chapter 2
SQL Syntax
SQL Syntax : SQL syntax is basically followed by sql commands which modifies the database tables such as "users" , "students" etc. All the SQL statements always starts with the key...
SQL : How to pass an array of parameters to stored procedure using XML?
In this article we will see how to pass an array of parameters to a stored procedure using xml. For illustration purpose we will be passing the
below list of id's :
<ids>
<id>1</id>
<id>2</id>
<...
SQL : How to get duplicate rows based on specific fields in table ?
In the following article we will go through a solution to a very common requirement of getting duplicate rows from SQL Server table based on specific columns.
Let us first create a table and add sample data to this table. Col1 in the table is an...
SQL : How to remove duplicates in SQL table?
In the following article we will go through a solution to a very common requirement of removing delete duplicate rows from SQL server table.
Let us first create a table and add sample data to this table. Col1 in the table is an identity column.
...
SQL : How to get count of duplicate records?
In the following article we will go through a solution to a very common requirement of getting count of duplicate rows from SQL server table.
Let us first create a table and add sample data to this table. Col1 in the table is an identity column....
SQL : How to get Nth record in SQL Table ?
In the following article we will go through a solution to a very common requirement of getting Nth record in a SQL server table.
Let us first create a table and add sample data to this table. Col1 in the table is an identity column.
CREATE TA...
SQL : How to find all tables containing column with specific name ?
Many times we come across a requirement of finding names of all tables which contain specific columns. We can get the answer by using the below query:
SELECT COL.name AS ColumnName, TAB.name AS TableName
FROM sys.columns COL
JOIN sys.tab...
SQL : Difference between UNION and UNION ALL
Both UNION and UNION ALL operators are used to combine the results of two or more SELECT statements. However the two differ as below:
1) UNION performs a DISTINCT on the result set, removing any duplicate rows.There is a performance hit when ...
Handling Duplicates using INSERT IGNORE
INSERT IGNORE:
INSERT IGNORE is used for handling duplicacy in a table as it ignores the query if the data is already present in the table and if the data does not exist then new row will be inserted.
Syntax:
INSERT IGNORE INTO tablename...
Inner Join
Using Inner Join:
It selects rows from both tables as long as there is a match between the column on which join is applied. Inner join is used to fetch data from more than one table.
Syntax:
SELECT columnname(s) FROM tablename1 INNER JO...
Pattern Matching using REGEXP
REGEXP:
It is similar to LIKE which is used to fetch data based on regular expression from a table.
Syntax:
SELECT columnname(s) FROM tablename WHERE columnname REGEXP pattern;
Example 1:
SELECT name FROM Employee WHERE name R...
DROP Statement
DROP Statement:
With the help of drop statement we can easily delete a table or a database and it is a DML(Data Manipulation Language) command.
Syntax to drop a table:
DROP table tablename;
Example:
DROP table Employee;
It ...
SQl:Create,Drop and Select Database Commands
1. CREATE DATABASE
Create database is a type of command used to create new SQL database.
Here is the syntax of CREATE DATABASE statement:-
CREATE DATABASE DatabaseName;
2.DROP DATABASE
Drop database is a type of command used to...
IN operator
IN Operator use:
It allows us to put multiple values in a where clause . With the help of this we can compare multiple values wtih where.
Syntax:
Select columnname(s) from Tablename where columnname IN(value1,value 2, .... value n);
...
Fetching Second Highest Salary
If we want to find highest salary we can use max() function simply.
Example:
SELECT max(salary) FROM Employee;
It will return the highest salary from Employee table.
But if we need to find the second highest salary then we have...
SQL Joins Introduction
SQL JOIN is used to combine data from two or more different table based on a common field between them in a relational database.
There are 5 types of JOIN:
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN
CROSS JOIN
INNER JOIN:...
Different types of SQL Joins
The SQL Joins are mostly used to combine records from two or more tables in a database for getting data. A JOIN defined as combining fields from 2 tables.
There are several operators that can be used to join tables. The opertaors that are used...
Prevent SQL Injection Attack
SQL injection is a technique that exploits a security vulnerability within the database layer of an application.Using this technique the attacker tries to run his own malicious query against the database.The key component of these malicious queri...
Function in SQL
Function in SQL
There are two type of function in sql
SQL aggregate function
1) AVG() - Returns the average value
SELECT AVG(column_name) FROM table_name
2) COUNT() - Returns the number of rows
SELECT COUNT(column_name...
Comparison of CTE, temp table and table variable
This post describes the major differences between CTE, temp table and table variables.
1) CTE
CTE stands for Common Table expressions. These are simple select queries and they do not create physical space in tempDB. Unlike temporary tabl...
Difference between truncate and delete
The following article captures the difference between truncate and delete.
1) Rollback Possibility:
It is possible rollback a DELETE operation but not a TRUNCATE operation.
2) Impact on Identity
TRUNCATE resets identity of a t...
Call a procedure with in procedure in SQL server
Call a procedure with in procedure in SQL server :-
While working in sql Some times you need to Calling one stored procedure within another stored procedure. So you can implement this using below sample code:---
//Store Procedure 1
CREATE...
Joins In SQL
Joins
There are different type of joins in SQL
1.Inner Join-Return all the values if there is a match in both the table.
2.Outer join
-left outer join-Return all the values from left table and the values matched from the right table.
...
SQL Joins
Joins
Joins in SQL are nothing but a technique to join the two table based on a common field.
OrderID CustomerID OrderDate
10308 2 1996-09-18
10309 37 1996-09-19
10310 77 1996-09-20
Custom...
Primary Key
Primary Key
A primary key in a table is a unique key that is the element in this column are unique and can not be null.
It is used to mantain the integrity.
It uniquely identify the row in the table.
It is a constraint on the table.
...
Indexing
The index is used to search the data in a table.
The index is basically a data structure that search our data.
It is applied usually on a column of a table.
It is usually a B-tree but can also be hash table and other depending upon the ...
Referential Integrity
Referential Integrity
Referential Integrity is a concept in which the tables shares a relationship between them and that should be consistent.
Ex:
If we have a table called Employee and the other Employee Salary and columns in them of na...
SQL Alter Table
SQL Alter Table
Using this query you can add , modify or delete columns in a existing table . It is also used to change the table name .
Syntax ->
Alter table table_Name Add column_Name column_Definition ;
If you want to add multip...