---
title: "SQL Clause"  
description: "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"  
author: "Anonymous User"  
published: 2011-07-11  
updated: 2018-03-22  
canonical: https://www.mindstick.com/articles/561/sql-clause  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# SQL Clause

In SQL there are many clauses which are widely used in [SQL database](https://www.mindstick.com/articles/337535/connecting-to-sql-databases-ado-dot-net-essentials). In [SQL server](https://www.mindstick.com/articles/34/create-table-in-microsoft-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](https://www.mindstick.com/interview/1909/when-do-you-use-where-clause-and-when-do-you-use-having-clause) is used to [extract](https://www.mindstick.com/forum/12883/how-to-extract-sub-string-between-two-string-pattern-using-javascript-jquery) only those [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) that fulfill specified criterion. The WHERE clause allows you to filter the [results](https://yourviews.mindstick.com/view/88282/boost-your-career-mindstick-technical-training-that-delivers-results) from an SQL statement - Select, [Update](https://yourviews.mindstick.com/view/83443/g7-summit-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](https://www.mindstick.com/news/2477/returning-ceo-bob-iger-dismisses-the-disney-apple-sale-as-pure-speculation) a large number of records can impact on performance.

The "TOP" clause will now allow us to do [Data Manipulation](https://www.mindstick.com/forum/1919/image-manipulation-c-sharp) 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 trueupdate top(3) STUDENT_DETAIL set name = 'kajal' where id = 102 
```

\

---

Original Source: https://www.mindstick.com/articles/561/sql-clause

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
