Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scroll thru recordset

Status
Not open for further replies.

jshanoo

Programmer
Apr 2, 2002
287
IN
Table customer
Custid CustName

1 emp #1
2 emp #2
3 emp #3
4 emp #4
5 emp #5
6 emp #6
7 emp #7

Above is the customer table
each time the user browes the tabel, a record # is stored in 'Table2'
next time when the user starts the browsing the table.
it should start at next record.
if the table browse ends at #5 then next time its should start from #6
and should go on like 6,7,1,2,3,4,5.

like 6 is the start and 5 is the end of record list.

is there any sql statement thru which i can do this.

regards
John philip

*** Even the Best, did the Bad and Made the Best ***

John Philip
 


IF CustID is a primary key and is contained in a clustered index (SQL Server):

select * from customer
where Custid > (select Custid from Table2)
union all
select * from customer
where Custid <= (select Custid from Table2)


Mark

&quot;You guys pair up in groups of three, then line up in a circle.&quot;
- Bill Peterson, a Florida State football coach
 
Hi mark
I am executing teh following query with mysql 4.0.17

it is not executing , can u sggest and alternative
Select A.*, C.areaid,C.areaname,C.pincode from maincontract A,
areamaster C,contracttype D Where A.Custid > (Select Custid from seekinfo
order by updttime desc limit 1)
Union All
Select A.*, C.areaid,C.areaname,C.pincode from maincontract A,
areamaster C,contracttype D Where A.Custid > (Select Custid from seekinfo
order by updttime desc limit 1)

*** Even the Best, did the Bad and Made the Best ***

John Philip
 
Sub-query is new to MySQL and you're probably running on a beta release.

Check the following (in the context of MySQL):
1. The syntax for using a Sub-query
2. Is the UNION statement supported? I believe its not!
3. This maybe a candidate for bugs in this release

 

You may find better answers to your question through the MySQL forum (forum436). But per on-line MySQL documentation:

- UNION is implemented in MySQL 4.0.0.
- Subquery syntax is

SELECT * FROM t1
WHERE column1 = (SELECT column1 FROM t2);

- If you want to use an ORDER BY for a total UNION result, you should use parentheses:

- I also noted in your query there are no relationships defined between the three tables (JOIN):

SELECT * FROM table1,table2
WHERE table1.id=table2.id;


Try parentheses around each select statement:

[red]([/red]
Select A.*, C.areaid,C.areaname,C.pincode
from maincontract A, areamaster C,contracttype D
Where A.Custid > (
Select Custid
from seekinfo
order by updttime desc limit 1
)
[red])[/red]
Union All
[red]([/red]
Select A.*, C.areaid,C.areaname,C.pincode
from maincontract A,areamaster C,contracttype D
Where A.Custid > (
Select Custid
from seekinfo
order by updttime desc limit 1
)
[red])[/red]




Mark

&quot;You guys pair up in groups of three, then line up in a circle.&quot;
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top