Monday, July 30, 2012

MySQL Data Retrieval

MySQL Data Retrieval using Select Statements

How to retrieve data in MySQl database,retrieving data is carried out by Select statements.Igive you example of the basic retrieval syntax.

SELECT   <attribute list>
FROM   <table list>
WHERE  <condition>

Example Simple Select queries

Table” Student”


 



To select the content of the columns named "LastName" and "Age" from the table above.
We use the following SELECT statement:

 SELECT <column> FROM <table>

SELECT Last_name,Age FROMStudent
    
The result goes like this:







The asterisk (*) is a quick way of selecting all columns!
 SELECT * FROM Student

 the result goes like this:
 



Example of  Select Distinct Syntax

SELECT DISTINCT column_name(s)
FROM table_name

Select P_id From Student

 









Example of MySQL WHERE Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value
SELECT * FROM Student
WHERE Age='18'
 The result is this:
hope this will help you.

No comments:

Post a Comment