MySQL first() function

The MySQL first function is used to return the first value of the selected column. Here, we use limit clause to select first record or more.

Syntax:

  1. SELECT column_name
  2. FROM table_name
  3. LIMIT 1;

MySQL first function example

To SELECT FIRST element:

Consider a table named “officers”, having the following data.

mysql first() 1

Execute the following query:

  1. SELECT officer_name
  2. FROM officers
  3. LIMIT 1;

Output:

mysql first() 2

To SELECT FIRST two records

  1. SELECT officer_name
  2. FROM officers
  3. LIMIT 2;

Output:

mysql first() 3

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *