Hi,
Using Access 2003.
I am trying to delete records from one table/query
("qryHistoryPer sonIDs") if they don't exist in another table
("qryDonations" ). But the SQL syntax I came up with is taking forever
or locking up Access 2003.
What am I doing wrong?
The code is below. dFromDate_pw and dToDate_pw are set to values of
date fields on a form. qryHistoryPerso nIDs contains one key field:
DoCmd.RunSQL "Delete * From qryHistoryPerso nIDs Where
qryHistoryPerso nIDs.personID Not In (Select qryDonations.pe rsonid From
qryDonations Where tblDonations.[DonationDate] Not Between #" &
dFromDate_pw & "# And #" & dToDate_pw & "# )"
I'd rather not manually read through the table as it has 4,000 records
and is growing.
Any ideas?
-pw
use paulwilliamson at spamcop dot net for e-mail 8 2779 pa************* *****@removespa mcop.net wrote: Hi,
Using Access 2003.
I am trying to delete records from one table/query ("qryHistoryPer sonIDs") if they don't exist in another table ("qryDonations" ). But the SQL syntax I came up with is taking forever or locking up Access 2003.
What am I doing wrong?
The code is below. dFromDate_pw and dToDate_pw are set to values of date fields on a form. qryHistoryPerso nIDs contains one key field:
DoCmd.RunSQL "Delete * From qryHistoryPerso nIDs Where qryHistoryPerso nIDs.personID Not In (Select qryDonations.pe rsonid From qryDonations Where tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "# And #" & dToDate_pw & "# )"
I'd rather not manually read through the table as it has 4,000 records and is growing.
Any ideas? -pw
use paulwilliamson at spamcop dot net for e-mail
The 'Not In (Select... syntax is known to be slow for larger tables.
If you use the wizard to create an unmatched query it will show you an
alternate syntax for returning the same records using a LEFT JOIN that
runs much faster.
James A. Fortune
On 16 Nov 2005 15:20:27 -0800, ji********@comp umarc.com wrote: pa************ ******@removesp amcop.net wrote: Hi,
Using Access 2003.
I am trying to delete records from one table/query ("qryHistoryPer sonIDs") if they don't exist in another table ("qryDonations" ). But the SQL syntax I came up with is taking forever or locking up Access 2003.
What am I doing wrong?
The code is below. dFromDate_pw and dToDate_pw are set to values of date fields on a form. qryHistoryPerso nIDs contains one key field:
DoCmd.RunSQL "Delete * From qryHistoryPerso nIDs Where qryHistoryPerso nIDs.personID Not In (Select qryDonations.pe rsonid From qryDonations Where tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "# And #" & dToDate_pw & "# )"
I'd rather not manually read through the table as it has 4,000 records and is growing.
Any ideas? -pw
use paulwilliamson at spamcop dot net for e-mail
The 'Not In (Select... syntax is known to be slow for larger tables. If you use the wizard to create an unmatched query it will show you an alternate syntax for returning the same records using a LEFT JOIN that runs much faster.
James A. Fortune
Hi James.
I did as you suggested and converted this (from the wizard SQL
Syntax):
SELECT tblHistoryPerso nIDs.PersonID
FROM tblHistoryPerso nIDs LEFT JOIN tblDonations ON
tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID
WHERE (((tblDonations .PersonID) Is Null));
To:
DoCmd.RunSQL "Delete * From tblHistoryPerso nIDs LEFT JOIN
tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID
WHERE tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "#
And #" & dToDate_pw & "#"
And I am getting "Specify the table containing the records you want to
delete". Can't figure it out. Am getting sleepy ;-0
Any ideas?
-pw
use paulwilliamson at spamcop dot net for e-mail pa************* *****@removespa mcop.net wrote: On 16 Nov 2005 15:20:27 -0800, ji********@comp umarc.com wrote:
pa************ ******@removesp amcop.net wrote: Hi,
Using Access 2003.
I am trying to delete records from one table/query ("qryHistoryPer sonIDs") if they don't exist in another table ("qryDonations" ). But the SQL syntax I came up with is taking forever or locking up Access 2003.
What am I doing wrong?
The code is below. dFromDate_pw and dToDate_pw are set to values of date fields on a form. qryHistoryPerso nIDs contains one key field:
DoCmd.RunSQL "Delete * From qryHistoryPerso nIDs Where qryHistoryPerso nIDs.personID Not In (Select qryDonations.pe rsonid From qryDonations Where tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "# And #" & dToDate_pw & "# )"
I'd rather not manually read through the table as it has 4,000 records and is growing.
Any ideas?
-pw
use paulwilliamson at spamcop dot net for e-mail
The 'Not In (Select... syntax is known to be slow for larger tables. If you use the wizard to create an unmatched query it will show you an alternate syntax for returning the same records using a LEFT JOIN that runs much faster.
James A. Fortune
Hi James.
I did as you suggested and converted this (from the wizard SQL Syntax):
SELECT tblHistoryPerso nIDs.PersonID FROM tblHistoryPerso nIDs LEFT JOIN tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID WHERE (((tblDonations .PersonID) Is Null));
To:
DoCmd.RunSQL "Delete * From tblHistoryPerso nIDs LEFT JOIN tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID WHERE tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "# And #" & dToDate_pw & "#"
And I am getting "Specify the table containing the records you want to delete". Can't figure it out. Am getting sleepy ;-0
Any ideas?
-pw
use paulwilliamson at spamcop dot net for e-mail
I didn't check your unmatched query, but when you get the unmatched
records the 'Not In (SELECT...' switches to 'IN (SELECT
tblHistoryPerso nIDs.PersonID ...
That is, the unmatched query should return the ones that are 'Not In'
so they are now 'In.'
I explained this in: http://groups.google.com/group/comp....63454c21472dc3
but I didn't do that great a job of explaining it there either. If
that doesn't help, post back and I'll organize my thoughts into
something a little more elegant and understandable. BTW, the ecommerce
code in that thread was from about six years ago and I cringed when I
saw it.
James A. Fortune
On 17 Nov 2005 00:02:35 -0800, ji********@comp umarc.com wrote: pa************ ******@removesp amcop.net wrote: On 16 Nov 2005 15:20:27 -0800, ji********@comp umarc.com wrote:
>pa************ ******@removesp amcop.net wrote: >> Hi, >> >> Using Access 2003. >> >> I am trying to delete records from one table/query >> ("qryHistoryPer sonIDs") if they don't exist in another table >> ("qryDonations" ). But the SQL syntax I came up with is taking forever >> or locking up Access 2003. >> >> What am I doing wrong? >> >> The code is below. dFromDate_pw and dToDate_pw are set to values of >> date fields on a form. qryHistoryPerso nIDs contains one key field: >> >> DoCmd.RunSQL "Delete * From qryHistoryPerso nIDs Where >> qryHistoryPerso nIDs.personID Not In (Select qryDonations.pe rsonid From >> qryDonations Where tblDonations.[DonationDate] Not Between #" & >> dFromDate_pw & "# And #" & dToDate_pw & "# )" >> >> I'd rather not manually read through the table as it has 4,000 records >> and is growing. >> >> Any ideas? >> >> -pw >> >> use paulwilliamson at spamcop dot net for e-mail > >The 'Not In (Select... syntax is known to be slow for larger tables. >If you use the wizard to create an unmatched query it will show you an >alternate syntax for returning the same records using a LEFT JOIN that >runs much faster. > >James A. Fortune Hi James.
I did as you suggested and converted this (from the wizard SQL Syntax):
SELECT tblHistoryPerso nIDs.PersonID FROM tblHistoryPerso nIDs LEFT JOIN tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID WHERE (((tblDonations .PersonID) Is Null));
To:
DoCmd.RunSQL "Delete * From tblHistoryPerso nIDs LEFT JOIN tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID WHERE tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "# And #" & dToDate_pw & "#"
And I am getting "Specify the table containing the records you want to delete". Can't figure it out. Am getting sleepy ;-0
Any ideas?
-pw
use paulwilliamson at spamcop dot net for e-mail
I didn't check your unmatched query, but when you get the unmatched records the 'Not In (SELECT...' switches to 'IN (SELECT tblHistoryPers onIDs.PersonID ...
That is, the unmatched query should return the ones that are 'Not In' so they are now 'In.'
That hurts! <g>
I explained this in:
http://groups.google.com/group/comp....63454c21472dc3
but I didn't do that great a job of explaining it there either. If that doesn't help, post back and I'll organize my thoughts into something a little more elegant and understandable.
Okay. Go ahead ;-)
BTW, the ecommerce code in that thread was from about six years ago and I cringed when I saw it.
Then I'll have to check it out for sure! :)
Thanks again,
-paul
James A. Fortune
-pw
use paulwilliamson at spamcop dot net for e-mail
> but I didn't do that great a job of explaining it there either. If that doesn't help, post back and I'll organize my thoughts into something a little more elegant and understandable.
Oops. I had a brain lapse and started a new thread instead of
replying to you. Oh well. Will be interesting to see if I get any
bites.
Thanks James,
-paul
-pw
use paulwilliamson at spamcop dot net for e-mail
On 17 Nov 2005 00:02:35 -0800, ji********@comp umarc.com wrote: pa************ ******@removesp amcop.net wrote: On 16 Nov 2005 15:20:27 -0800, ji********@comp umarc.com wrote:
>pa************ ******@removesp amcop.net wrote: >> Hi, >> >> Using Access 2003. >> >> I am trying to delete records from one table/query >> ("qryHistoryPer sonIDs") if they don't exist in another table >> ("qryDonations" ). But the SQL syntax I came up with is taking forever >> or locking up Access 2003. >> >> What am I doing wrong? >> >> The code is below. dFromDate_pw and dToDate_pw are set to values of >> date fields on a form. qryHistoryPerso nIDs contains one key field: >> >> DoCmd.RunSQL "Delete * From qryHistoryPerso nIDs Where >> qryHistoryPerso nIDs.personID Not In (Select qryDonations.pe rsonid From >> qryDonations Where tblDonations.[DonationDate] Not Between #" & >> dFromDate_pw & "# And #" & dToDate_pw & "# )" >> >> I'd rather not manually read through the table as it has 4,000 records >> and is growing. >> >> Any ideas? >> >> -pw >> >> use paulwilliamson at spamcop dot net for e-mail > >The 'Not In (Select... syntax is known to be slow for larger tables. >If you use the wizard to create an unmatched query it will show you an >alternate syntax for returning the same records using a LEFT JOIN that >runs much faster. > >James A. Fortune
Hi James.
I did as you suggested and converted this (from the wizard SQL Syntax):
SELECT tblHistoryPerso nIDs.PersonID FROM tblHistoryPerso nIDs LEFT JOIN tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID WHERE (((tblDonations .PersonID) Is Null));
To:
DoCmd.RunSQL "Delete * From tblHistoryPerso nIDs LEFT JOIN tblDonations ON tblHistoryPerso nIDs.PersonID = tblDonations.Pe rsonID WHERE tblDonations.[DonationDate] Not Between #" & dFromDate_pw & "# And #" & dToDate_pw & "#"
And I am getting "Specify the table containing the records you want to delete". Can't figure it out. Am getting sleepy ;-0
Any ideas?
-pw
use paulwilliamson at spamcop dot net for e-mail
I didn't check your unmatched query, but when you get the unmatched records the 'Not In (SELECT...' switches to 'IN (SELECT tblHistoryPers onIDs.PersonID ...
That is, the unmatched query should return the ones that are 'Not In' so they are now 'In.'
I explained this in:
http://groups.google.com/group/comp....63454c21472dc3
but I didn't do that great a job of explaining it there either. If that doesn't help, post back and I'll organize my thoughts into something a little more elegant and understandable. BTW, the ecommerce code in that thread was from about six years ago and I cringed when I saw it.
James A. Fortune
I got it James:
strSQL_pw = _
"DELETE * From tblHistoryPerso nIDs " & _
"WHERE NOT EXISTS " & _
"(SELECT * " & _
"FROM tblDonations " & _
"WHERE tblDonations.Pe rsonID =
tblHistoryPerso nIDs.PersonID " & _
"AND (DonationDate < #" & dFromDate_pw & "# " & _
"OR DonationDate > #" & dToDate_pw & "#))"
DoCmd.RunSQL strSQL_pw
And it ran quickly when I put in a date range to delete all the
records.
Phew! That was an important stumbling block because I have to do it
for a bunch of other combinations on this form.
Thanks!
-paul
-pw
use paulwilliamson at spamcop dot net for e-mail pa************* *****@removespa mcop.net wrote: On 17 Nov 2005 00:02:35 -0800, ji********@comp umarc.com wrote:
I got it James:
strSQL_pw = _ "DELETE * From tblHistoryPerso nIDs " & _ "WHERE NOT EXISTS " & _ "(SELECT * " & _ "FROM tblDonations " & _ "WHERE tblDonations.Pe rsonID = tblHistoryPerso nIDs.PersonID " & _ "AND (DonationDate < #" & dFromDate_pw & "# " & _ "OR DonationDate > #" & dToDate_pw & "#))"
DoCmd.RunSQL strSQL_pw
And it ran quickly when I put in a date range to delete all the records.
Phew! That was an important stumbling block because I have to do it for a bunch of other combinations on this form.
Thanks!
-paul -pw
use paulwilliamson at spamcop dot net for e-mail
I was dubious about the 'Not Between' also. I'm glad you found a way
to do it efficiently. The way I suggested should also have worked
quite well though.
James A. Fortune
On 17 Nov 2005 14:16:59 -0800, ji********@comp umarc.com wrote: pa************ ******@removesp amcop.net wrote: On 17 Nov 2005 00:02:35 -0800, ji********@comp umarc.com wrote:
I got it James:
strSQL_pw = _ "DELETE * From tblHistoryPerso nIDs " & _ "WHERE NOT EXISTS " & _ "(SELECT * " & _ "FROM tblDonations " & _ "WHERE tblDonations.Pe rsonID = tblHistoryPerso nIDs.PersonID " & _ "AND (DonationDate < #" & dFromDate_pw & "# " & _ "OR DonationDate > #" & dToDate_pw & "#))"
DoCmd.RunSQL strSQL_pw
And it ran quickly when I put in a date range to delete all the records.
Phew! That was an important stumbling block because I have to do it for a bunch of other combinations on this form.
Thanks!
-paul -pw
use paulwilliamson at spamcop dot net for e-mail
I was dubious about the 'Not Between' also. I'm glad you found a way to do it efficiently. The way I suggested should also have worked quite well though.
James A. Fortune
Yeah, that Not Between was a killer. Thank you much for your help!
-pw
use paulwilliamson at spamcop dot net for e-mail This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Noddy |
last post by:
We have an application that updates a row in a table. Sometimes Oracle
does not respond for over 10 seconds. This is after an insert. It
seems that there is a lock somewhere. This is a multi user system.
Records can be added 3+ pr. second.
We have a procedure stored that does the actuall insert. Documented
below. As you can see the insert is pretty straight forward. (look at
the last section in the procedure).
What can cause this...
|
by: robert |
last post by:
been ruminating on the question (mostly in a 390/v7 context) of
whether, and if so when, a row update becomes an insert/delete.
i assume that there is a threshold on the number of columns of
the table, or perhaps bytes, being updated where the engine just
decides, screw it, i'll just make a new one.
surfed this group and google, but couldn't find anything.
the context: we have some java folk who like to parametize/
|
by: Maurice KRAIT |
last post by:
Hello all,
I use ACCESS 97.
I want to delete all records of a table "TABLE RESULT" , the name of
which includes spaces.
It seems to me that the correct syntax is as follows :
DoCmd.RunSQL "Delete * FROM 'TAB RESULT';"
Tne table name is enclosed with apostrophes.
|
by: David |
last post by:
I am trying to insert an employee number into the EmpNbr field in my
main table from a form where I add a new employee to my employee table.
I was hoping this command would work, but it isn't.
DoCmd.RunSQL "INSERT INTO VALUES ()", 0
This is the only field I want to populate in the main table from this
form. there are three other fields in the main table that I want to
leave unpopulated.
|
by: John Bailo |
last post by:
Has anyone downloaded the DirectX SDK...it's taking me forever!
I want to do some GDI programming in c# using VC#Express
| |
by: travlintom |
last post by:
Hi. I'm new to VB.net and am used to working with recordsets (much
easier). I have a datagrid that, when the user double clicks on a row,
I am giving them a chance to delete it. I thought this would be simple
but it's taking me forever. I am getting an error when I try to delete
the record. I can't figure out what I'm doing wrong.
The error is "Object reference not set to an instance of an object".
None of the incredibly overpriced books...
|
by: Sam777 |
last post by:
I was under the impression that creating the app_offline.htm file at the
root of the webapp would cause all handles to be closed so that the app could
be removed. Unfortunately, this isn't the case. One handle remains open.
Debugging shows that it's actually the IIS cache and not ASP.NET that owns
this handle. During IIS shutdown, the handle is closed with the following
stack trace:
ChildEBP RetAddr
0006fbe4 5a403e05...
|
by: jujube |
last post by:
Hi, I thought I found a great command in RunSQL, but....
In my Unload event for a form, I added some clean-up code:
Private Sub Form_Unload(Cancel As Integer)
If Not IsNull(Me.ID.Value) And Not IsEmpty(Me.ID.Value) Then
DoCmd.RunSQL "delete * from tblStarDudes where id=" & Me.ID.Value
End If
End Sub
When it reached the delete, a msg popped up to confirm deletion of a number of records equal to everything in my table...
|
by: jl2886 |
last post by:
I would like a all records from (a table) where .="Rejected" and input those records into the (a table). Both tables are exactly the same as far as structure. I have created a macro with one RunSql Statement.
INSERT INTO SELECT ALL FROM WHERE .="Rejected"
It says there is a syntax error, do you have any ideas?
Also, could I run this from a form, or do I have to create a macro in order to do it.
Actually, I want to then delete the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |