Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-27-2016, 07:05 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default How to filter correctly

I have a table of users with a field ID Number
And a table of Items that hold a number that relates to users
I'm using a ADODataSet

I have a simple filter that works finishing with: - where ID = 1;

1/ I want to automate the DataSet rewrite the script before a refresh so: - ID = another user number
2/ in the list of items their may be 100 items, how can I make SQL script list Items 20 to 40 as an example

Last edited by lexd; 04-27-2016 at 10:04 AM.
Reply With Quote
  #2  
Old 04-28-2016, 08:20 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

#1 - AdoDataset has a Filter property
#2 - Depends on your sql language, in MSSQL you can do this by a ROW_NUMBER and a where
Reply With Quote
  #3  
Old 04-28-2016, 10:52 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default

No I'm using good old MySQL
And doing a query is very simple

but if the query is large can I save memory and acquire sections (20 to 40) in the result. And if (40 to 60) is asked later to collect that set
Will BeforeRefresh event be ideal to update the query before the data-set operates the query

Last edited by lexd; 04-28-2016 at 10:55 AM.
Reply With Quote
  #4  
Old 04-28-2016, 12:19 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

Quote:
how can I make SQL script
Quote:
And doing a query is very simple
You ask for a query and then you say it's easy???

So now I'm assuming you want it done in VCL.
ADOQuery has a RecordSet
On this you could set the PageSize and AbsolutePage. According to the documentation it should do the trick.

NOTE: I don't have any experience with it, I only know it's there...
Reply With Quote
  #5  
Old 04-28-2016, 09:52 PM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default

I found it
answer is: - Limit

Last edited by lexd; 04-29-2016 at 12:52 AM.
Reply With Quote
  #6  
Old 04-29-2016, 07:05 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

You lost me

This is MySQL syntax, so in the query.
You already found that easy, so I didn't answer on that part.

Then you ask about BeforeRefresh event and answer with Limit

Glad you figured it out, because I couldn't give you this answer based upon how this thread evolved...

So a small tip, if you would've asked for a query (sql syntax) in your question for MySQL you would've gotten this answer yesterday already
Reply With Quote
Reply

Tags
database, delphi

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:54 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.