Presentation is loading. Please wait.

Presentation is loading. Please wait.

MY SQL Eng: SAHAR. Introduction to SQL What is SQL? When a user wants to get some information from a database file, he can issue a query A query is a.

Similar presentations


Presentation on theme: "MY SQL Eng: SAHAR. Introduction to SQL What is SQL? When a user wants to get some information from a database file, he can issue a query A query is a."— Presentation transcript:

1 MY SQL Eng: SAHAR

2 Introduction to SQL What is SQL? When a user wants to get some information from a database file, he can issue a query A query is a user–request to retrieve data or information with a certain condition SQL is a query language that allows user to specify the conditions. (instead of algorithms )

3 Language SQL Data Multiplication Language ( DML) لغة معالجة البيانات Data Definition Language (DDL) لغة تعريف البيانات

4 Data Multiplication Language ( DML) Select Insert Update Delete

5 Select Statement SELECTField Name FROM Table Name SELECTField Name FROM Table Name EX: We have This Table With the name MyTable And we need to select ID Field IDNameSalary 1Ali700 2Ahmed800

6 Solution Select Id From MyTable Result: ID 1 2

7 EX: We have This Table With the name MyTable And we need to select ID,Name Fields Select Id, Name From MyTable IDName 1Ali 2Ahmed Result:

8 To Select all table Fields Select * From Table Name We Use * instead of write of all Fields

9 IDNameSalary 1Ali700 2Ahmed800 Then If We Apply This For above Example Solution will be: Select * From MyTable

10 Where … If We Have a condition in using Select we can use where Select Field name From Table Name Where Condition

11 Where Conditions = Equal <> Not Equal > More Than < Less Than >= More Than or equal <= Less Than or equal

12 EX: From Above Table Select All data about Ali Solution Select * From MyTable Where Name =“ Ali”

13 INSERT Statement INSERT Statement Insert into Table name (Fields name) Values ( Field values) Insert into Table name (Fields name) Values ( Field values) Ex : ID, Name, Address, Note) Values (4,’Kindy’,’Cairo’,’SQL’) Ex : Insert Into MyTable (ID, Name, Address, Note) Values (4,’Kindy’,’Cairo’,’SQL’)

14 The Result will be : NoteAddressNameID VB,MYSQL CairoIbrahim1 VB.NetGezaBasma2 ASPAlexOla3 SQLCairoKindy4

15 Delete Statement Delete Statement Delete From Table Name Where Condition EX: Where Name=‘Kindy’ Delete Form MyTable Where Name=‘Kindy’

16 The Result will be : NoteAddressNameID VB,MYSQL CairoIbrahim1 VB.NetGezaYomna2 ASPAlexOla3

17 UpDate Statement UpDate Statement UpDate Table name Set Field Name = values UpDate Table name Set Field Name = values Ex : Yomna Basma Ex : Up date MyTable set Yomna instead of Basma Solution Name = ‘Yomna’ Where Name=‘Basma’ Update MyTable Set Name = ‘Yomna’ Where Name=‘Basma’

18 NoteAddressNameID VB,MYSQL CairoIbrahim1 VB.NetGezaYomna2 ASPAlexOla3 SQLCairoKindy4

19 Data Definition Language ( DDL) CREATE ALTER DROP RENAME

20 Create Statement Create Table Table Name Field Type ….. Char(X) VarChar(X) Integer Date

21 EX: Create Table MyTable (ID Integer, Name Varchar(15),Address Varchar(15),Note Varchar(50)) NoteAddressNameID

22 Alter Statement Alter Table Table Name Add

23 EX: Alter Table MyTable Add Date date DateNoteAddressNameID

24 Rename Statement Alter Table Table Name Rename to New Name EX: Alter Table MyTable Rename To Sales

25 Drop Statement Drop Table Table Name EX: Drop Table MyTable


Download ppt "MY SQL Eng: SAHAR. Introduction to SQL What is SQL? When a user wants to get some information from a database file, he can issue a query A query is a."

Similar presentations


Ads by Google