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;