Re: Operator 'in' in a select statement

From: Dirk Schmidtpott <Dirk.Schmidtpott_at_t-online.de>
Date: 1996/05/25
Message-ID: <4o7bs0$bdt_at_news00.btx.dtag.de>#1/1


scomp_at_mbox.vot.it (Stefano Compieta) wrote:

>Hi,
 

>I don't know how the operator 'IN' work retrieving columns in a select
>statement . For example in the following select :
 

> SELECT col1 FROM table1 WHERE col1 IN (10,20,15,30)
 

>columns are displayed
 

> col1
> --------
> 30
> 15
> 20
> 10
 

>order is different to the order I write in the select statement .
>How I can do if I want to retrieve columns in the order I write them ?
 

>Thanks ,

> Stefano Compieta .

Hi Stefano,
I think your ordering problem has nothing to do with the "in" operator. With the "in" operator you can specify a set of values to be searched for like you did it in your example. But the order of the retrieved rows is arbitrary unless you order them explicitly or apply an index to them. By the way, this is true for any select. If you add an order by clause to your example, you will still not get the rows in your requested order, because they are ordered numerical. The solution is to add a column to the table, which contains the order level for the other column.

I hope, that helps.

Dirk Schmidtpott Received on Sat May 25 1996 - 00:00:00 CEST

Original text of this message