Re: SQL Question
Posted in 1997
Nils Myklebust (Nils.Myklebust@idg.no) wrote:
{ Tin Zaw <tzaw@qualcomm.com> wrote:
{ :Does any one know how to do following in SQL (Informix in particular)?
{ :I need to get the first row a SELECT statement finds, not all the rows.
{ :e.g. SELECT * from my_table where row_value < 10 ....
{ :should return first row with row_value < 10, even the table has
{ :many qualifying rows.
{ There is no direct way of doing this in Informix.
{ If you use some language (4GL, NewEra, C...) you can allways open a
{ cursor and fetch only the first row.
Welll.....
select * from my_table where rowid = (select min(rowid) from
my_table where row_value < 10)
would give you one row. Depending on what you mean by "first row", this
would be it.
Note on versions of informix without a rowid, pick some other unique
field or add one. (Like a serial typed field)
"There is no way ... in Informix" has been said in error so many times, I
can't count.
--
gburnore@databasix.com mailto:gburnore@databasix.com
---------------------------------------------------------------------------
If we had bacon, we could have bacon and eggs, if we had eggs.
---------------------------------------------------------------------------
Gary L. Burnore | '۳''''''۳'''''''''''۳
DataBasix | '۳''''''۳'''''''''''۳
San Francisco, CA | '۳''''''۳'''''''''''۳
| '۳ 3 4 1 4 2 '' 6 9 0 6 9 '۳
http://www.databasix.com | Official Proof of Purchase
===========================================================================