Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   DB-Aware (http://www.delphipages.com/forum/forumdisplay.php?f=5)
-   -   How to filter correctly (http://www.delphipages.com/forum/showthread.php?t=217431)

lexd 04-27-2016 07:05 AM

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

Norrit 04-28-2016 08:20 AM

#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

lexd 04-28-2016 10:52 AM

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

Norrit 04-28-2016 12:19 PM

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...

lexd 04-28-2016 09:52 PM

I found it
answer is: - Limit

Norrit 04-29-2016 07:05 AM

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


All times are GMT. The time now is 09:05 AM.

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