Select Distinct

From: Peter (ched_at_yahoo.com)
Date: 08/19/04


Date: Thu, 19 Aug 2004 20:06:39 GMT

I am trying to create a resultset from an Access DB. I am using the a Select
Distinct statement to get unique results.

Then I am using a while resultset.next .....statement to step thru the
result set. The SQL works perfect in Access so I am happy with that. The
problem is that when I start to loop thru the resultset with a print
statement I get the results I expeccted until it should drop out of the
loop, but it doesnt. I then get a SQL error. If I remove the distinct
command the while loop runs correctly.

Any idea why using a SELECT DISTINCT messes up a while loop?????

Thanks for any help you can give.



Relevant Pages

  • Re: newbie: jsp / ms sql - nested queries problem
    ... > I'm writing html in a while loop in a jsp page. ... Statement can only have one active ResultSet at a time. ... You will need to set the server configuration to use ...
    (comp.lang.java.databases)
  • force sql server to handle a subquery as correlated
    ... My only suggestion is store the initial highest value in ... a variable and just keep on incrementing the variable ... you do need to do it in a loop. ... >I want to insert a resultset of a select statement into ...
    (microsoft.public.sqlserver.programming)
  • Re: How to accessing columns of a query-result by index
    ... I want to access the columns of my resultset by index. ... > dreaming of something like this: ... > for i in 1..rec_data%colcount loop ... you may even want to consider dynamically generating an anonymous PL/SQL ...
    (comp.databases.oracle.server)
  • RE: force sql server to handle a subquery as correlated
    ... Your suggstion might be helpful if there is no other who can insert data to the table a the same time, when running the loop. ... >>I want to insert a resultset of a select statement into ... > a table wich has a non automated primary key. ...
    (microsoft.public.sqlserver.programming)