Saturday, 12 March 2011

SQL MAX Command

                                                  Some time we wanna search max value from table.like students's mark.so this time MAX command is very usefull.

see this command,

SELECT MAX(mark) FROM student;

SQL MIN Function

                                                              When you want to get MIN value from the table used this function.ok see this table,


                                                        table is student




      used this command you can get minimum value from student table       

                                            


Group BY

 Now consider this command


SELECT MIN(mark) 
FROM student
GROUP BY mark

it out put is this.







there  have'nt no them names.ok let us see this example, r
NAME & MARK

consider following  command

SELECT name,MIN(mark)
FROM student
GROUP BY mark

 it output may be,







SEARCH DATA

                                     A company has been thousand  of employ details.so how can get specify name from this table.ok, let us see how to use search,consider following simple code.what is your idea?




SELECT *
FROM `first` where  id=1;



                              That  * means select all data from 'first' table.& there has been a specify id.it is '1'. ok ,see what may be output,






Update data from a Table

                                                                             The UPDATE statement is used to update existing data in a table.


Syntax
UPDATE table
SET column1=value, column2=value2
WHERE some_column=some_value





Update specify data 


UPDATE first
SET id='001', data='Jaya'
WHERE LastName='jayarathna' AND FirstName='praneeth';



    


Normal update code

UPDATE first
SET id='001', data='praneeth';



Insert data to a table

                                                                 Data is inserted  to row from this command.





INSERT INTO first
VALUES ('praneeth','Jayarathna');












now type this command to view the data.

SHOW COLUMNS FROM first;















Insert Data Only in Specified Columns

Create a Table

      

                                        1)First of all Open the MYSQL command Line.Then log your account.Next type this code for creating a  database.(attention ! you have to use this mark ( ) finally of every 
command.)
(you can use suitable name instead of the word "first")


CREATE DATABASE  first;




  2) selecting the  database is next step.()


USE first;


3)now we selected the database which we made first.then type this command for creating a database.



CREATE TABLE first (
          id INT,
          data VARCHAR(100)
        ) TYPE=innodb;


                               CREATE TABLE mean a SQL  keyword.first means just only a name.it means you can use your favorite name.INT means a data type.id means name of INT.and you can be use any thing for the VARCHAR. 





                       Now Table has been created.


4)If you want to see Table type this command


SHOW TABLES;




                                                     

Start Programming with MYSQL command line


                                                                                         for programming with Mysql used "Mysql command Line Client" software.it is in where you install mysql software. Now click as this path  MYSQL command Line client.



then open this window.now type the password & press Enter.
when password correct, this window will open



Getting Start MYSQL

                              Click start-pro gramme files-MYSQL-MYsql Administrator




                                      
1)type sever host box "localhost", then  type port number 3306
2)now type you typed User name & passwords.
3)click OK button.
any change in mysql you can do this MY sql Administrator.

Installing MySQL

                

    
                                            
                                   I use windows xp operating System.so I will explain how to Install the Mysql  to windows xp.
First of All you must be download "Mysql sever".go this link http://dev.mysql.com/downloads/mysql/5.0.html  .when you log my sql site you will seen,as this window. 
  


2.select  MySQL Community Server 5.1 .On the next screen click download .




System to Installing MySQL







1)click Next to see a screen for choosing the type of installation.




2)select n\TYPICAL & click next button.






3).click install button.
Click Skip Signup and then click Next. The Wizard Completes. MySQL is now installed on your 
machine.






Running the MySQL


1)Choose Standard Configuration for normal install. 




2) select both of all and choose Server name to MySQL
3)now better you select Modify Security Settings & type passwords.


4.then click the next button & as you will seen this window.


5.final click Execute button.
when you don,you will seen next this window 





Friday, 11 March 2011

SQL

                    Structured Query Language 


                           
 




                                   It mean Structured query language.The first incarnation of SQL appeared in 1974.SQL is a standard language for accessing and manipulating databases.think a bit, when you want to your site add details of members.so what you do?OK your Answer I don't know.but most of web owners are using this language.because of it can be do easy way to use insert,update,delete & search data's.otherwise it can do determining .

There are 4 reseon of sql


1)SQL Commands
  Basic SQL statements for storing, retrieving, and manipulating data in a relational database.
  
2)Table Manipulation 
  How SQL statements are used to manage tables inside the database.

3)Advanced SQL 
   Advanced SQL commands.  

4)SQL Syntax
     A single page that lists the syntax for all the SQL commands in this tutorial.