Re: Creating a Delete Query from an Unmatched Query

Tech-Archive recommends: Speed Up your PC by fixing your registry



I would try the following:

DELETE DistinctRow Table2.*
FROM Table2 INNER JOIN [Table2 Without Matching Table1]
ON [Table2 Without Matching Table1].test=[table2].[test]

You can only reference ONE table in the DELETE clause. You were referencing
two

Another way of writing this
DELETE DistinctRow Table2.test
FROM Table2 LEFT JOIN Table1 ON Table2.test=Table1.test1
WHERE (((Table1.test1) Is Null));




"hgbwhite" <hgbwhite@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7D85FB15-8E72-4A4B-B9D6-00649D2CD256@xxxxxxxxxxxxxxxx
I tried this and it did not work. Here is the actual code from the
unmatched
query and the delete query that uses the unmatched query. The unmatched
query's name is "Table2 Without Matching Table1".

UNMATCHED QUERY: SELECT Table2.test
FROM Table2 LEFT JOIN Table1 ON Table2.test=Table1.test1
WHERE (((Table1.test1) Is Null));

DELET QUERY: DELETE Table2.*, [Table2 Without Matching Table1].test
FROM Table2, [Table2 Without Matching Table1]
WHERE ((([Table2 Without Matching Table1].test)=[table2].[test]));

Any other Ideas?



"KARL DEWEY" wrote:

Try not joining the query but use the query field as criteria.

"hgbwhite" wrote:

I am trying to delete records from table1 that are not in table2.

What I did......

I created an UNMATCHED query from table1 and table2. I then created a
DELETE Query using table1 and the UNMATCHED query using an inner join.

I keep getting the error:

"Could not delete from specified tables. (Error 3086)
You tried to delete data from one or more tables, but the deletion
could not
be completed.

Possible causes:

You do not have permission to modify the table. To change your
permissions
assignments, see your system administrator or the table's creator.
The database was opened for read-only access. The database is read-only
for
one of these reasons:
You used the OpenDatabase method and opened the database for read-only
access.
The database file is defined as read-only in the database server
operating
system or by your network.
In a network environment, you do not have write privileges for the
database
file.
In Microsoft® Visual Basic®, you used the Data control and set the
ReadOnly
property to True.
To delete the data, close the database, resolve the read-only
condition, and
then reopen the file for read/write access."

I have confirmed all of the possible problems from above.

Does anyone know why this is not working or a better way to accomplish
the
same thing?


.



Relevant Pages

  • Re: Move record from one table to another
    ... Building a database isn't like building ... Set a "pushFlag" column in the record in table1 to a specific ... Sets the "status" field in the new record in table2 to a specific ... If a duplicate is not found, ...
    (comp.databases.ms-access)
  • Re: Noob question on Access table merging
    ... database, some of the items I already have in my database. ... Now create a query with Table1 and Table2. ... Dbl-Click on it and select the option to select All records from Table1 and only those that match in Table2. ...
    (comp.databases.ms-access)
  • Re: counting in a query
    ... Say you've got two instances of 12345 in table1 ... and only one in table2. ... >>> How do I get it to give me a count of the zip5 field in each database ... >>> Joe Robison ...
    (microsoft.public.fox.programmer.exchange)
  • Re: MS SQL copy new and modified rows from TABLE1 to TABLE2
    ... Or ar the tables in different databases on different servers? ... were ever added to Table1. ... there in Table2. ... they are on the same server and in the same Database. ...
    (comp.databases.ms-sqlserver)
  • Re: real world singleton class example?
    ... I've used them for database classes before. ... What is the use of a singleton is when running PHP? ... table1 and table2 tables within the database. ...
    (comp.lang.php)