pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
select only the first record
3+ messages / 3 participants
[nested] [flat]

* select only the first record
@ 2001-07-10 13:09 juerg.rietmann@pup.ch
  2001-07-10 13:31 ` Re: select only the first record Jan Wieck <JanWieck@Yahoo.com>
  2001-07-10 13:38 ` Re: select only the first record Christof Glaser <gcg@gl.aser.de>
  0 siblings, 2 replies; 3+ messages in thread

From: juerg.rietmann@pup.ch @ 2001-07-10 13:09 UTC (permalink / raw)
  To: pgsql-sql

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
============================================




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: select only the first record
  2001-07-10 13:09 select only the first record juerg.rietmann@pup.ch
@ 2001-07-10 13:31 ` Jan Wieck <JanWieck@Yahoo.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Jan Wieck @ 2001-07-10 13:31 UTC (permalink / raw)
  To: juerg.rietmann@pup.ch; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: select only the first record
  2001-07-10 13:09 select only the first record juerg.rietmann@pup.ch
@ 2001-07-10 13:38 ` Christof Glaser <gcg@gl.aser.de>
  1 sibling, 0 replies; 3+ messages in thread

From: Christof Glaser @ 2001-07-10 13:38 UTC (permalink / raw)
  To: juerg.rietmann@pup.ch; pgsql-sql

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-07-10 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-10 13:09 select only the first record juerg.rietmann@pup.ch
2001-07-10 13:31 ` Jan Wieck <JanWieck@Yahoo.com>
2001-07-10 13:38 ` Christof Glaser <gcg@gl.aser.de>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox