Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Create Procedure AS Select From Where AND: 'London' 'WA1 1DP'

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

1.Field is column in the table .

2.
Stored Procedure With Multiple Parameters

Setting up multiple parameters is very easy. Just list each parameter and
the data type separated by a comma as shown below.

The following SQL statement creates a stored procedure that selects


Customers from a particular City with a particular PostalCode from the
"Customers" table:

Example
CREATE PROCEDURE SelectAllCustomers @City nvarchar(30),
@PostalCode nvarchar(10)
AS
SELECT * FROM Customers WHERE City = @City AND PostalCode
= @PostalCode
GO;

Execute the stored procedure above as follows:

Example
EXEC SelectAllCustomers @City = 'London', @PostalCode = 'WA1
1DP';
3.
SQL UNIQUE Constraint

The UNIQUE constraint ensures that all values in a column are


different.

Both the UNIQUE and PRIMARY KEY constraints provide a guarantee


for uniqueness for a column or set of columns.

A PRIMARY KEY constraint automatically has a UNIQUE constraint.


However, you can have many UNIQUE constraints per table, but only
one PRIMARY KEY constraint per table.

INNER JOIN: The INNER JOIN keyword selects all rows from both the
tables as long as the condition satisfies

LEFT JOIN: This join returns all the rows of the table on the left side of
the join and matching rows for the table on the right side of join
FULL JOIN: FULL JOIN creates the result-set by combining result of
both LEFT JOIN and RIGHT JOIN. The result-set will contain all the
rows from both the tables. The rows for which there is no matching, the
result-set will contain NULL values.

KEY DIFFERENCE:

 SQL is a language which is used to operate your database


whereas MySQL was one of the first open-source database
available in the market
 SQL is used in the accessing, updating, and manipulation of data in
a database while MySQL is an RDBMS that allows keeping the
data that exists in a database organized
 SQL is a Structured Query Language and MySQL is a RDBMS to
store, retrieve, modify and administrate a database.
 SQL is a query language while MYSQL is a database software

PRIMARY KEY vs UNIQUE KEY


For an organization or a business, there are so many physical entities (such as
people, resources, machines, etc.) and virtual entities (their Tasks, transactions,
activities). Typically, business needs to record and process information of those
business entities. These business entities are identified within a whole business
domain by a Key.

As per RDBMS prospective, Key (a.k.a Candidate Key) is a value or set of values
that uniquely identifies an entity.

For a DB-Table, there are so many keys are exist and might be eligible for Primary
Key. So that all keys, primary key, unique key, etc are collectively called as
Candidate Key. However, DBA selected a key from candidate key for searching
records is called Primary key.

Difference between Primary Key and Unique key

1. Behavior: Primary Key is used to identify a row (record) in a table, whereas


Unique-key is to prevent duplicate values in a column (with the exception of a null
entry).
2. Indexing: By default SQL-engine creates Clustered Index on primary-key if not
exists and Non-Clustered Index on Unique-key.
3. Nullability: Primary key does not include Null values, whereas Unique-key can.
4. Existence: A table can have at most one primary key, but can have multiple
Unique-key.
5. Modifiability: You can’t change or delete primary values, but Unique-key
values can.

What is CLAUSE in SQL?


SQL clause helps to limit the result set by providing a condition to the query. A clause helps to filter the
rows from the entire set of records.

For example – WHERE, HAVING clause.

You might also like