SQL COMMANDS EXAMPLES

 Delphi About oops Error Handle DLL DllForms Sql Commands XML XML  Extension API MessageBox  API DELPHI Memory Leakage I|O ERROR Guest Book Malai



create table sivamm(LastName varchar(20),FirstName varchar(20), Address varchar(20),City varchar(20))
insert sivamm values('Pettersen','Kari','Storgt 20','Stavanger')
insert sivamm values('gerald','robert','Stuht 39','Sihty')

select * from sivamm

-------------------------------------------------------------------------------- 

LastName             FirstName            Address              City                
--------------        ---------------      ---------------     --------------------
Pettersen            Kari                    Storgt 20               Stavanger
gerald                robert                   Stuht 39                 Sihty

---------------------------------------------------------------------------------------


INSERT INTO sivamm
VALUES ('Hetland', 'Camilla', 'Hagabakka 24', 'Sandnes')

After entering the record, please use the following statement

select * from sivamm

 ------------------------------------------------------------------------------

LastName             FirstName            Address                  City                
-------------------- -------------          ----------------         --------------------
Pettersen               Kari                   Storgt 20               Stavanger
gerald                   robert                Stuht 39                 Sihty
Hetland                Camilla               Hagabakka 24         Sandnes

-----------------------------------------------------------------------------------

 


UPDATE sivamm set city='amer'
where FirstName=  'Kari'

BEFORE UPDATE ------------------------------------------------

LastName             FirstName            Address                  City                
-------------------- -------------          ----------------         --------------------
Pettersen               Kari                   Storgt 20               Stavanger
gerald                   robert                Stuht 39                 Sihty
Hetland                Camilla               Hagabakka 24         Sandnes

AFTER UPDATE----------------------------------------------------------

LastName             FirstName            Address              City                
--------------------       --------------------         --------------------     --------------------
Pettersen             Kari                    Storgt 20                  amer
gerald                 robert                   Stuht 39                  Sihty
Hetland              Camilla                 Hagabakka 24         Sandnes

--------------------------------------------------- 

 

------Delete from sivamm where LastName ='Pettersen'
         select * from Orders

 

BEFORE DELETE------------------------------------------------

LastName             FirstName            Address                  City                
-------------------- -------------          ----------------         --------------------
Pettersen               Kari                   Storgt 20               Stavanger
gerald                   robert                Stuht 39                 Sihty
Hetland                Camilla               Hagabakka 24         Sandnes

AFTER DELETE----------------------------------------------------------

LastName             FirstName            Address              City                
--------------------       --------------------         --------------------     --------------------
gerald                 robert                   Stuht 39                  Sihty
Hetland              Camilla                 Hagabakka 24         Sandnes

(--The record of 'Pettersen' has been Deleted)

-------------------------------------------------- 

 

TRY THESE COMMANDS ND CHECK WHAT IS THE OUTPUT.

SELECT * FROM Sivamm
WHERE FirstName='Kari'
AND LastName='Pettersen'


SELECT * FROM Sivamm
WHERE FirstName='Kari'
or LastName='Pettersen'

SELECT * FROM Sivamm
WHERE LastName IN ('Pettersen','gerald')

SELECT * FROM Sivamm WHERE LastName
BETWEEN 'Pettersen' AND 'gerald'

 

select count(LastName) from Sivamm

select count(distinct LastName) from sivamm