-2

For example, what if I wanted to retrieve the first 3 records from my query results. How can I do this?

user272735
  • 10,473
  • 9
  • 65
  • 96
  • Use `limit` in MySQL: `select * from your_table order by some_column limit 3` But this only makes sense in combination with a sort order. Otherwise the result could be different every time you execute the query – juergen d Jan 09 '14 at 09:36
  • 2
    Your tags are confusing. Are you looking for an SQL statement in MySQL or in Oracle dbms? PL/SQL is a programming language in Oracle dbms and is not needed here. – Thorsten Kettner Jan 09 '14 at 09:41

2 Answers2

0
SELECT * FROM table1 where rownum <=3;

If ordering is considered then

select * from 
  (select * FROM table1 order by column_name)
 where rownum <=3;

But wait, how this question is related to Oracle and MySql at the same time? Anyways, this will work in Oracle.

San
  • 4,508
  • 1
  • 13
  • 19
0

You may try this (works on db2 sql):

     select * from <table_name> fetch first 3 rows only with ur;

Regards

5122014009
  • 3,766
  • 6
  • 24
  • 34