Re: How to do a "select any" using Informix SQL?
Posted in 1994
> Does anybody know a simple and efficient way of selecting any record in a > non-singleton select statement without having to resort to 4GLxs > open, fetch and close? The easiest way, assuming the tuples returned will have the same values, is to use SELECT DISTINCT colnames, but this is very inefficient as it has to read all the rows then group them in a temp table. If all the cols you are selecting are in an index, then something like SELECT MIN(col1),MIN(col2) would do the job. By reading the whole lot through an index then not only does it only need to touch one row, but it will do a key-only select (ie. it can get all it needs from the index page so it doesn't need to bother reading the data page). This is very efficient. OPEN..FETCH..CLOSE is the best way. akent@cix.compulink.co.uk (Andy Kent) ------------------------------------- +44 117 974 2815