Pages

Thursday, 2 January 2014

The SELECT Command

The SELECT command of SQL lets you make queries on the database.

Example:-
                  mysql > SELECT name,species
                          ->  FROM pet;


Now in SELECT command you have to specify the table i.e, from which table and is done by FROM and writing the table name just after FROM.
name,species in the command is columns name in pet table. 

Accessing Database

When we start our queries first of all we have to know that , a database contain tables and a tables contain data . Thus if we need to use data we first need to enter in database and then in table.

We can enter in any database by using USE  <DATABASE NAME>;

   It can be used as , Suppose a database named Menagerie 
Now this command used as  USE Menagerie; 



+---------------------------------------------------------------------------------------------------------+
    NOTE :-  There is a space gap between USE and Menagerie in previous Command.
                   We use this semi-colon sign ";" to close any statement.
+---------------------------------------------------------------------------------------------------------+
Now if we want to see the list of our databases then we use SHOW DATABASES; 
It will display all the names of databases.



Now if we want to see the list of our tables in database then we use SHOW TABLES;        

             
TO EXIT FROM MY SQL YOU CAN TYPE EXIT;

Tuesday, 31 December 2013

Connection of Database

This process is very helpful for beginners . It create Sample DataBase in My SQL.

Requirement :-  SampleDB  (Downloaded From Download Area).

Follow these simple steps very carefully

1.  Open My SQL
2. Enter your password
+--------------------------------------------------------------------------------------------------------+
   Note:- Save SampleDB in C:/                                                                                                         
               As files in SampleDB contain directory as C:/SampleDB                                                       
+--------------------------------------------------------------------------------------------------------+
3.  Type SOURCE C:/SampleDB/MENA.sql  in command line
     
   

4.  Hit Enter

5.   Now type     SOURCE C:/SampleDB/crEmpDep.sql      and    Press Enter.
      and then  type     SOURCE C:/SampleDB/crStudent.sql      and    Press Enter.
6.  Now type   use menagerie;    & then press Enter  (Type all in blue color including ';').
                       Show tables;  
        If you are watching screen like this     then you have Done.  (Notice dept,empl,event,pet,student)



        IF Not then try it again carefully this time.
  These process just join the database to your My SQL which we will need in learning queries .



  

Downloading My SQL


My SQL Essential 5.1.73 win32 .msi   32-Bit      Size  38.8 MB             DOWNLOAD
            
My SQL Essential 5.1.73 win64 .msi   64-Bit      Size  31.5 MB             DOWNLOAD

          Sample Database                                        Size  3.63 KB              DOWNLOAD