A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to use Delete Query for specific for rows 5



 
 
Thread Tools Display Modes
  #1  
Old November 26th, 2009, 12:16 AM posted to microsoft.public.access.queries
Steph_canoe[_2_]
external usenet poster
 
Posts: 3
Default How to use Delete Query for specific for rows 5

I would to use a Delete Query for all rows of Table A after Row #5.

Is there a way I can filter so the delete query remove Rows 5 in Table A ?

Thank you
  #2  
Old November 26th, 2009, 12:35 AM posted to microsoft.public.access.queries
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default How to use Delete Query for specific for rows 5

The concept of a row number is completely foreign to a table in a relational
database. Tables are sets and as such have no intrinsic order. You'll need
to specify a sort order which determines which are the top 5 rows you want to
retain. Assuming you can do this on a column in the table then you'd use a
subquery to return the top 5 rows and restrict the rows deleted to those not
returned by the subquery, e.g.

DELETE *
FROM [Table A]
WHERE [YourField] NOT IN
(SELECT TOP 5
[YourField]
FROM [Table A]
ORDER BY [YourField]);

Ken Sheridan
Stafford, England

Steph_canoe wrote:
I would to use a Delete Query for all rows of Table A after Row #5.

Is there a way I can filter so the delete query remove Rows 5 in Table A ?

Thank you


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:21 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.