dbms presentationnnnn

38
1

Upload: sumi-haque

Post on 02-Jul-2015

68 views

Category:

Engineering


1 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Dbms presentationnnnn

1

Page 2: Dbms presentationnnnn

2

Page 3: Dbms presentationnnnn

Name ID

1. Setu haque

3

Page 4: Dbms presentationnnnn

The Commands That Are Going To Be Discussed

4

1.SELECT

2.SELECT DISTINCT

3.WHERE

4.ORDER BY

5.AND

6.OR

Page 5: Dbms presentationnnnn

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

Page 6: Dbms presentationnnnn

Demo Database

SELECT

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

Page 7: Dbms presentationnnnn

SELECT

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

Page 8: Dbms presentationnnnn

SELECT

SELECT Column Example

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

table:The Practical Output

Page 9: Dbms presentationnnnn

SELECT

SELECT Column Example

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

columns from the “Students" table:

The Practical Output

Page 10: Dbms presentationnnnn

SELECT Column Example

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

the “Students" table:

The Practical Output

SELECT

Page 11: Dbms presentationnnnn

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

Page 12: Dbms presentationnnnn

SELECT

DISTINCT Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

Page 13: Dbms presentationnnnn

SELECT

DISTINCT SELECT DISTINCT Column Example

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

table:The Practical Output

Page 14: Dbms presentationnnnn

SELECT

DISTINCT SELECT DISTINCT Column Example

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

from the “Students" table:

The Practical Output

Page 15: Dbms presentationnnnn

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;

Page 16: Dbms presentationnnnn

WHERE

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

Page 17: Dbms presentationnnnn

WHERE

WHERE Column Example

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

“CSC434", in the “Students" table:

The Practical Output

Page 18: Dbms presentationnnnn

WHERE

WHERE Column Example

The following SQL statement selects all the students from the CourseNo

“CSC434", in the “Students" table:

The Practical Output

Page 19: Dbms presentationnnnn

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

Page 20: Dbms presentationnnnn

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]

Page 21: Dbms presentationnnnn

ORDER

BYDemo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

Page 22: Dbms presentationnnnn

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

Page 23: Dbms presentationnnnn

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

Page 24: Dbms presentationnnnn

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

Page 25: Dbms presentationnnnn

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

Page 26: Dbms presentationnnnn

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;

Page 27: Dbms presentationnnnn

AND Operator

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

Page 28: Dbms presentationnnnn

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

Page 29: Dbms presentationnnnn

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

Page 30: Dbms presentationnnnn

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;

Page 31: Dbms presentationnnnn

Demo Database

StudentId StudentName Course Section

13103007 Bithi Akter CSC433 D

13103010 Sanjida Tasnim CSC434 E

13103013 Shohana Akter CSC434 D

OR Operator

Page 32: Dbms presentationnnnn

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

Page 33: Dbms presentationnnnn

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

Page 34: Dbms presentationnnnn

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);

Page 35: Dbms presentationnnnn

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

Page 36: Dbms presentationnnnn

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

Page 37: Dbms presentationnnnn

Any Question?

Page 38: Dbms presentationnnnn