VisualBuilder
  Home > Database > Tutorials > Getting Data with Select Statement - SQL tutorial
Tell a friend
Link to us
Total Members
      Members: 84648
     
Sitemap Forum Chat
Home
SQL Tutorial Tutorial Home
1 . History of SQL
2 . SQL Components: An Overview
3 . Data Types in SQL
4 . Planning a Database: An Example: -
5 . Creating Tables
6 . Inserting Data using Insert
7 . Getting Data with Select Statement
8 . Working with Operators
9 . Selecting Unique rows with Distinct
10 . Arraging Data with Order by
11 . Working with Strings
12 . SQL AND
13 . Basic SQL Funtion
14 . Sub-Queries, Nested Queries
15 . Constraints in the Table
16 . SQL UPDATE
17 . View
18 . Relationships in a RDBMS
19 . Structure Modification,Updation and Deletion
 
Database Group Home
Database Discussion
Database Members (506)
Database Resources
Database Source Code (0)
Database Articles (0)
Database Blogs
Database Jobs
Database Components (0)
Database Books
Database Websites (0)
Database News (0)
Database Q & A (14)
- Database Ask Question
- Database Questions
- Database Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Grails Tutorial
Hibernate Tutorial
Java 1.6 Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Service-Oriented Architecture (SOA) Using Java Web Services Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (436 )
Source Code (3275 )
Articles (11 )
Components (1589 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise


Database sql Tutorial
 Getting Data with Select Statement
  << Prev: Inserting Data using Insert Next: Working with Operators >>
Select: - Select is used to fetch the data from the tables in the database. Following is the syntax for using the select statement.

Syntax: -

SELECT <Column Name> FROM <Table Name>

;



Example: -
If you want to see Teacher Name from the Teacher Table:-

Select Teacher_Name from Teacher;

The above query will fetch the names of all the teachers in the teacher table.

To fetch all the details of the teachers we will use the following query: -

Select * from Teacher;

The above query will display all the details of the teachers. Here '*' refers to all the columns.

To fetch the details of more than one column (not all the columns), we will use delimeter (,) between the column names.
For example: -

Select Teacher_Name, Qualification from Teacher; will display the Teacher Names and their qualifications.

Where Clause: - Where clause is used to fetch the data according according to the conditions given by the user with the
help of operators. The following is the syntax for using where: -

Syntax: -
SELECT <Column Name>
FROM

<Table Name>
WHERE <Condition>


Example: -

If you want to see the ID of the students who secured percentage of marks equal to 65%.

Select Student_ID from Marks where MarksPercentage = 65;

Similarly we can use the different operators with where clause: -

Select Student_ID from Marks where MarksPercentage > 65;

Select Student_ID from Marks where MarksPercentage < 65;

Select Student_ID from Marks where MarksPercentage < > 65;


Order By: - It is used to fetch the data in the given order (Ascending or Descending).
The following is the syntax for order by: -

Syntax: -
SELECT <column Name>
FROM <Table Name> [WHERE ]
ORDER BY [ASC, DESC]
Example: -

If you want to see the details of the students in ascending order according to the name.

Select * from Student order by StudentName;

In the above example we have not mentioned the type of the ordering because by default it is ascending order but for
the descending order we have to specify the order: -

Select * from Student order by StudentName Desc; will display the data in the descending order.

  << Prev: Inserting Data using Insert Next: Working with Operators >>
Database Sql Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
VoIP Internettelefonie
cell phone accessories
toll free conference call
Video Surveillance
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising