|
|
| Author |
Message |
aryanpa1
New User
Joined: 26 May 2007 Posts: 17 Location: Chennai
|
|
|
|
Hi ,
Can any body suggest me to retrieve the first row from a table in efficient way.
Thanks,
pavan |
|
| Back to top |
|
 |
References
|
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8732 Location: 221 B Baker St
|
|
|
|
Hello,
What is meant by "first row"?
Sequential files have a first and last record, but databases do not have the same.
Keep in mind that most database processing is done via one or more keys. There is no "first". |
|
| Back to top |
|
 |
Anuj D.
Global Moderator
Joined: 22 Apr 2006 Posts: 2229 Location: Phoenix, AZ
|
|
|
|
Pavan,
This can be one way:
| Code: |
SELECT * FROM table Name
FETCH FIRST ROW ONLY
WITH UR; |
|
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8732 Location: 221 B Baker St
|
|
|
|
Hello,
That will fetch one record - not sure i understand how that would be "the first row from a table" . It would be the first row that particular query fetches, but that does not imply the first row in the table.
As i mentioned earlier, until what "first row" really means is defined, there is no way to read it and besides, there is not a "first row in the table" concept in most database systems. |
|
| Back to top |
|
 |
aryanpa1
New User
Joined: 26 May 2007 Posts: 17 Location: Chennai
|
|
|
|
Hi Anuj ,
It worked. Thankyou... |
|
| Back to top |
|
 |
stodolas
Senior Member
Joined: 13 Jun 2007 Posts: 647 Location: Wisconsin
|
|
|
|
| Code: |
SELECT * FROM table Name
FETCH FIRST ROW ONLY
WITH UR; |
Is extremely useless. You just arbitrarily selected a row. It could be different the next time you do it, or it could be the same for the life of the table.
This is a complete waste of a query without a ORDER BY clause. |
|
| Back to top |
|
 |
|
|