IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Fetch rec


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lakshmibala

New User


Joined: 16 Jun 2004
Posts: 47

PostPosted: Thu Sep 30, 2004 6:08 pm
Reply with quote

Hi all,

i have a doubet can v retrieve rows frm middle of a table i.e frm 100 to 125 , how is it possible?

Regards
Lakshmi
Back to top
View user's profile Send private message
ConnoisseuR

New User


Joined: 06 Aug 2004
Posts: 8
Location: india

PostPosted: Tue Oct 05, 2004 9:20 am
Reply with quote

Each row in the TABLE is provided with an unique id i.e. TABLE ID.
you can put a simple select query like this:

SELECT *
FROM TABLE_NAME
WHER TABLE_ID BETWEEN 100 AND 500;

Thanks
santosh
Back to top
View user's profile Send private message
lakshmibala

New User


Joined: 16 Jun 2004
Posts: 47

PostPosted: Wed Oct 06, 2004 8:15 pm
Reply with quote

HI,

u said the range from 100 to 500, but i am asking 100th row from 500th row ok, r u under stand my question,

regrds
Lakshmi
Back to top
View user's profile Send private message
sandip_datta

Active User


Joined: 02 Dec 2003
Posts: 150
Location: Tokyo, Japan

PostPosted: Thu Oct 07, 2004 9:03 am
Reply with quote

Lakshmi,

I am really confused about the sentence structure of your last post. May be I don't know that much good english. Can you please put some verb in the sentence in proper place and let us know what actually do you want?

Regards,
Sandip.
Back to top
View user's profile Send private message
anuradha

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

PostPosted: Fri Oct 08, 2004 2:00 pm
Reply with quote

Hi Lakshmi,

Quote:
u said the range from 100 to 500, but i am asking 100th row from 500th row ok, r u under stand my question


Do u want the rows from 100 to 500 or what?

If Yes then just modify the query given by santosh accordingly.

SELECT *
FROM TABLE_NAME
WHER TABLE_ID BETWEEN 99 AND 501

So,I hope this will fetch the rows from 100 to 500.

Thanks,
Anu
Back to top
View user's profile Send private message
ConnoisseuR

New User


Joined: 06 Aug 2004
Posts: 8
Location: india

PostPosted: Tue Oct 12, 2004 12:19 pm
Reply with quote

hi lakshmi , i got your problem.this can be done by FETCH FIRST N ROWS

QUERY WILL BE LIKE THIS

SELECT *
FROM TABLE_NAME
WHERE TABLE_ID = 500
FETCH FIRST 100 ROWS ONLY


hope this makes it clear now.


santosh
Back to top
View user's profile Send private message
ConnoisseuR

New User


Joined: 06 Aug 2004
Posts: 8
Location: india

PostPosted: Tue Oct 12, 2004 12:30 pm
Reply with quote

hi anuradha,
i would like to correct you that BETWEEN implies including both the boundaries.

so if we write

select *
from table
where field between 100 and 500

this query will process the records including the 100th and 500th.


santosh
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Code Multi Row fetch in PL1 program PL/I & Assembler 1
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts fetch the record number from FMNMAIN ... CLIST & REXX 10
Search our Forums:

Back to Top