...

Database Managment - MySql

Back to Course

Lesson Description


Lession - #1306 SQL Select Top


The SELECT TOP clause is used to specify the number of records to return.

The SELECT TOP condition is useful on enormous tables with great many records. Returning a large records can impact performance.

Syntax



SELECT column_name(s>
FROM table_name WHERE condition LIMIT number;


Let's see an example



-- create
CREATE TABLE EMPLOYEE (
  empId INTEGER PRIMARY KEY,
  name TEXT NOT NULL,
  dept TEXT NOT NULL
>
; -- insert INSERT INTO EMPLOYEE VALUES (0001, 'Clark', 'Sales'>
; INSERT INTO EMPLOYEE VALUES (0002, 'Dave', 'Accounting'>
; INSERT INTO EMPLOYEE VALUES (0003, 'Ava', 'Sales'>
; -- fetch SELECT * FROM EMPLOYEE limit 2;

Output


Try it here

mysql tutorial mysql tutorialspoint Tutorials mysql geeksforgeeksGeeks for Geeks