RE: [PHP-WIN] SQL to select a set of records
| From: | Herhuth, Ron | Date: | Fri, 06 Feb 2004 14:12:21 +0000 |
| Subject: | RE: [PHP-WIN] SQL to select a set of records | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-22748@lists.php.net to get a copy of this message | ||
Okay I tried this and while it doesn't error out I still only get the
first 10 records, if I change the first number I get the number of records
that I changed the number to. If I change the second number nothing
happens.
SELECT TOP 10 dbo.individual.id, last_name, first_name
FROM dbo.individual
WHERE dbo.individual.id NOT IN
(SELECT TOP 30 individual.id
FROM dbo.individual)
Thanks for the help,
Ron
>From: Svensson, B.A.T. (HKG)
>To: 'php-windows@lists.php.net'
>Sent: 02/06/2004 8:42 AM
>set nocount on
>create table test (a int , b char(1))
>create table test_tmp (a int , b char(1))
>
>
>insert into test values (1, 'a')
>insert into test values (2, 'a')
>insert into test values (3, 'b')
>insert into test values (4, 'b')
>insert into test values (5, 'c')
>insert into test values (6, 'c')
>insert into test values (7, 'd')
>insert into test values (8, 'd')
>insert into test values (9, 'e')
>insert into test values (10, 'e')
>insert into test values (11, 'e')
>insert into test values (12, 'e')
>insert into test values (13, 'e')
>insert into test values (14, 'e')
>insert into test values (15, 'e')
>insert into test values (16, 'e')
>insert into test values (17, 'e')
>insert into test values (18, 'e')
>insert into test values (19, 'e')
>insert into test values (20, 'e')
>insert into test values (21, 'e')
>insert into test values (22, 'e')
>insert into test values (23, 'e')
>insert into test values (24, 'e')
>insert into test values (25, 'e')
>insert into test values (26, 'e')
>insert into test values (27, 'e')
>insert into test values (28, 'e')
>insert into test values (29, 'e')
>insert into test values (30, 'e')
>
>insert into test_tmp
>select top 25 *
>from test
>order by a asc
>
>select *
>from test_tmp
>where a in(
> select top 15 a
> from test_tmp
> order by a desc
>)
>order by a asc
>
>drop table test_tmp
>drop table test
>
>
>
>
>-----Original Message-----
>From: Stuart
>To: David Felton
>Cc: Nadim Attari; php-windows@lists.php.net; Herhuth, Ron
>Sent: 2004-02-06 13:44
>Subject: Re: [PHP-WIN] SQL to select a set of records
>
>David Felton wrote:
>> SELECT TOP 10 dbo.Table_MIS_Files.File_ID
>> FROM dbo.Table_MIS_Files
>> WHERE dbo.Table_MIS_Files.File_ID NOT IN
>> (SELECT TOP 25 dbo.Table_MIS_Files.File_ID
>> FROM dbo.Table_MIS_Files)
>
>Shouldn't this be...
>
>SELECT TOP 25 dbo.Table_MIS_Files.File_ID
>FROM dbo.Table_MIS_Files
>WHERE dbo.Table_MIS_Files.File_ID NOT IN
>(SELECT TOP 10 dbo.Table_MIS_Files.File_ID
>FROM dbo.Table_MIS_Files)
>
>That will get rows 11-25.
>--
>Stuart
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>