Berkay Turancı
Berkay Turancı

Reputation: 3459

SQL IN Clause By Giving Just Start and End Numbers Only

Is there a way to give an undefined set for the clause of IN ?

Such as:

select * from ABC WHERE MY_ID IN (X TO Y)

Example: If I give X to 3 and Y to 8 ;

select * from ABC WHERE MY_ID IN (3, ... , 8)

This should be identical to :

select * from ABC WHERE MY_ID IN (3, 4, 5, 6, 7, 8)

Upvotes: 0

Views: 96

Answers (3)

bonCodigo
bonCodigo

Reputation: 14361

Can try this as well...

select * from abc where id >= 3 and id <=8

Upvotes: 2

John Woo
John Woo

Reputation: 263803

how about BETWEEN

SELECT * FROM ABC WHERE MY_ID BETWEEN 3 AND 8

Upvotes: 1

rs.
rs.

Reputation: 27457

You need this

select * from ABC WHERE MY_ID between 3 and 8

Upvotes: 6

Related Questions