dbms presentationnnnn

Post on 02-Jul-2015

68 Views

Category:

Engineering

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

It is helpful for mysql presentation........

TRANSCRIPT

1

2

Name ID

1. Setu haque

3

The Commands That Are Going To Be Discussed

4

1.SELECT

2.SELECT DISTINCT

3.WHERE

4.ORDER BY

5.AND

6.OR

Function of SELECTThe SELECT statement is used to select data from a database.

The SQL SELECT StatementThe SELECT statement is used to select data from a database.

The result is stored in a result table, called the result-set.

SQL SELECT Syntax

SELECT ColumnName,ColumnName FROM TableName;

and

SELECT * FROM TableName;

SELECT

5

Demo Database

SELECT

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

SELECT

??????????????????

SELECT

SELECT Column Example

The following SQL statement selects the “StudentId" columns from the “Students"

table:The Practical Output

SELECT

SELECT Column Example

The following SQL statement selects the “StudentId“ and “StudentName”

columns from the “Students" table:

The Practical Output

SELECT Column Example

The following SQL statement selects the all columns by using *(staric sign) from

the “Students" table:

The Practical Output

SELECT

Function of SELECT DISTINCTThe SELECT DISTINCT statement is used to return only distinct (different) values.

The SQL SELECT DISTINCT StatementIn a table, a column may contain many duplicate values; and sometimes you only

want to list the different (distinct) values.

The DISTINCT keyword can be used to return only distinct (different) values.

SQL SELECT DISTINCT Syntax

SELECT DISTINCT ColumnName,ColumnName FROM TableName;

SELECT

DISTINCT

SELECT

DISTINCT Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

SELECT

DISTINCT SELECT DISTINCT Column Example

The following SQL statement selects the “CourseNo" columns from the “Students"

table:The Practical Output

SELECT

DISTINCT SELECT DISTINCT Column Example

The following SQL statement selects the “StudentId“ and “CourseNo” columns

from the “Students" table:

The Practical Output

WHERE

Function of WHEREThe WHERE clause is used to filter records.

The SQL WHERE ClauseThe WHERE clause is used to extract only those records that fulfill a specified

criterion.

SQL WHERE Syntax

SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName

operator value;

WHERE

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

WHERE

WHERE Column Example

The following SQL statement selects the “Section" columns from the CourseNo

“CSC434", in the “Students" table:

The Practical Output

WHERE

WHERE Column Example

The following SQL statement selects all the students from the CourseNo

“CSC434", in the “Students" table:

The Practical Output

WHERE

Operators in The WHERE Clause

The following operators can be used in the WHERE clause:

Operator Description

= Equal

<> Not equal. Note: In some versions of SQL this

operator may be written as !=

> Greater than

< Less than

>= Greater than or equal

<= Less than or equal

BETWEEN Between an inclusive range

LIKE Search for a pattern

IN To specify multiple possible values for a column

ORDER BY

Function of ORDER BY DISTINCTThe ORDER BY keyword is used to sort the result-set.

The SQL ORDER BY KeywordThe ORDER BY keyword is used to sort the result-set by one or more columns.

The ORDER BY keyword sorts the records in ascending order by default. To sort

the records in a descending order, DESC keyword is used.

SQL ORDER BY Syntax

SELECT ColumnName,ColumnName FROM TableName ORDER BY

ColumnName,ColumnName ASC|DESC; [Here, ASC=Ascending &

DESC=Descending]

ORDER

BYDemo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

ORDER BY

ORDER BY Column Example

The following SQL statement selects the "CourseNo" from the “Students" table,

sorted by the “StudentId" column:

The Practical Output

ORDER BY

ORDER BY Column Example

The following SQL statement selects the "CourseNo" from the “Students" table,

sorted by the “StudentId" column in descending form:

The Practical Output

ORDER BY

ORDER BY Column Example

The following SQL statement selects all students from the “Students" table, sorted

by the “StudentId" column:

The Practical Output

ORDER BY

ORDER BY Column Example

The following SQL statement selects all students from the “Students" table, sorted

by the “StudentId" column in descending form:

The Practical Output

AND Operator

Function of AND OperatorsThe AND operators are used to filter records based on more than one condition.

The SQL AND OperatorsThe AND operator displays a record if both the first condition AND the second

condition are true.

SQL AND Syntax

SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName

operator value AND ColumnName operator value;

AND Operator

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

AND Operator

AND Operator Column Example

The following SQL statement selects the “StudentId” from the Section “D" AND the

CourseNo “CSC434", in the “Students" table:

The Practical Output

AND Operator

AND Operator Column Example

The following SQL statement selects all students from the Section “D" AND the

CourseNo “CSC434", in the “Students" table:

The Practical Output

OR Operator

Function of OR OperatorsThe OR operators are used to filter records based on more than one condition.

The SQL OR OperatorsThe OR operator displays a record if either the first condition OR the second

condition is true.

SQL OR Syntax

SELECT ColumnName,ColumnName FROM TableName WHERE

ColumnName operator value OR ColumnName operator value;

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

OR Operator

OR Operator Column Example

The following SQL statement selects the “StudentName” and “Section” coloumns

from the StudentId “13103013" OR the CourseNo “CSC434", in the “Students"

table:The Practical Output

OR Operator

OR Column Example

The following SQL statement selects all students from the StudentId “13103013"

OR the CourseNo “CSC434", in the “Students" table :

The Practical Output

OR Operator

Combination of AND & OR Operators

Combining AND & OR OperatorsWe can also combine AND and OR (use parenthesis to form complex

expressions).

SQL Combination AND & OR Operators Syntax

SELECT ColumnName,ColumnName FROM TableName WHERE

ColumnName operator value AND (ColumnName operator value OR

ColumnName operator value);

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

Combination of AND & OR Operators

Combination of AND & OR Operators

Combination AND & OR Operators Column Example

The following SQL statement selects all students from the CourseNo “CSC434"

AND the StudentId must be equal to “13103013" OR the Section must be equal to

“E", in the “Students" table:

The Practical Output

Any Question?

top related