Thread: select only the first record

select only the first record

From
juerg.rietmann@pup.ch
Date:
Hello there

Is it possible to do a query and selecting only the first record in ad
table ?

e.g. select FIRST * from cars

Tx in advance ... jr

============================================
PFISTER + PARTNER, SYSTEM - ENGINEERING AG
Juerg Rietmann
Grundstrasse 22a
6343 Rotkreuz
Switzerland

phone: +4141 790 4040
fax: +4141 790 2545
mobile: +4179 211 0315
============================================



Re: select only the first record

From
Jan Wieck
Date:
juerg.rietmann@pup.ch wrote:
> Hello there
>
> Is it possible to do a query and selecting only the first record in ad
> table ?
>
> e.g. select FIRST * from cars
   You  can either use a CURSOR and FETCH only the first row, or   use LIMIT (non-standard).
   And you might  want  to  explicitly  ORDER  the  result  set,   otherwise   exchange   "FIRST"   with  "ONE-RANDOM"
in your   question.
 


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



Re: select only the first record

From
Christof Glaser
Date:
On Tuesday, 10. July 2001 15:09, juerg.rietmann@pup.ch wrote:
> Hello there
>
> Is it possible to do a query and selecting only the first record in
> ad table ?
>
> e.g. select FIRST * from cars

SELECT * FROM cars ORDER BY <your pkey> LIMIT 1;

Without ORDER BY, there is no "first" record - any record could be 
returned.

Regards,
Christof Glaser