Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
    Single Page App
    Bootstrap
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> Database >> SQL Clause
SQL Clause
SQL Clause


by Arun Singh on 7/11/2011 5:43:59 PM

Views: 1892       Comments: 0

SQL Clause

In SQL there are many clauses which are widely used in SQL database. In SQL server mainly two clauses are widely used namely: WHERE and TOP. Let’s see these two descriptions briefly.

SQL WHERE Clause:

The WHERE clause is used to extract only those records that fulfill specified criterion. The WHERE clause allows you to filter the results from an SQL statement - Select, Update, or Delete statement.

Example: Using WHERE clause

--- select data field from STUDENT_DETAIL table where  condition are true

 select * from STUDENT_DETAIL where id = 102 

Desired Output:

102         VARUN SINGH

SQL TOP Clause:

The TOP clause is used to specify the number of records to return. The TOP clause can be very useful on large tables with thousands of records. Returning a large number of records can impact on performance.

The "TOP" clause will now allow us to do Data Manipulation and also allow similar criteria results to be displayed by using the TIES option.

Example: Using TOP Clause

--- select top 3 data field from STUDENT_DETAIL

 select top(3)* from STUDENT_DETAIL 

//with condition

--- select top 3 data field from STUDENT_DETAIL

 select top(3)* from STUDENT_DETAIL where id = 102 

--- update top 3 data field from STUDENT_DETAIL where condition is true

update top(3) STUDENT_DETAIL set name = 'kajal' where id = 102 

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Arun SinghRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 3704
Advertisement
MindStick SurveyManager
Advertise with Us
  
Copyright © 2009 - 2014MindStick. All Rights Reserved.