473,721 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JOIN query: What happens when you delete a row?

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 records AND THE PARENT record are
deleted -- definitely not what I wanted.

I have another query that could be described the same way, except in that
form when I delete a record only the child record is deleted from the
original tables. It doesn't seem to make any difference whether the join is
inner or outer, nor whether parent data is displayed in the detail section.

So here's the question: What determines the outcome? How do I write the
query, and/or design the form, to be sure that when I want to delete a child
record in the form, the parent record will survive? Are the rules for this
documented somewhere?

---
Bob Bridges, rh*****@attglob al.net, cell 336 382-7313
(hotel) 612 869-7704 xt 118, fax 612 869-7383

/* A crooked politician may be faithful to his wife, but a man who deceives
his own wife can't be relied on to deal honestly with the public. We have
been getting this backward lately. We've been assuming that you can have
public virtue without private virtue. -Joseph Sobran, 1998 */
Mar 3 '07 #1
5 4143
if you are able to delete a parent record and leave *any* of its' child
records intact, then you haven't enforced referential integrity in your
table relationships. recommend you do that immediately.

hth
"Bob Bridges" <rh*****@attglo bal.netwrote in message
news:45e90dd7$1 @kcnews01...
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 records AND THE PARENT record are
deleted -- definitely not what I wanted.

I have another query that could be described the same way, except in that
form when I delete a record only the child record is deleted from the
original tables. It doesn't seem to make any difference whether the join
is
inner or outer, nor whether parent data is displayed in the detail
section.
>
So here's the question: What determines the outcome? How do I write the
query, and/or design the form, to be sure that when I want to delete a
child
record in the form, the parent record will survive? Are the rules for
this
documented somewhere?

---
Bob Bridges, rh*****@attglob al.net, cell 336 382-7313
(hotel) 612 869-7704 xt 118, fax 612 869-7383

/* A crooked politician may be faithful to his wife, but a man who
deceives
his own wife can't be relied on to deal honestly with the public. We have
been getting this backward lately. We've been assuming that you can have
public virtue without private virtue. -Joseph Sobran, 1998 */


Mar 3 '07 #2
Message received, but that's not my question. Hear it again, please: I
have a query with joined records, and when I hit the <Delkey while viewing
that data in a form I want it to delete just the child record, not the
parent. It works that way in one form but not another, and I haven't yet
been able to figure out what the difference is between the two so that I can
control it. Anyone know what makes that determination.

--- "tina" <no****@address .comwrote in message
news:t2******** **********@bgtn sc05-news.ops.worldn et.att.net...
if you are able to delete a parent record and leave *any* of its' child
records intact, then you haven't enforced referential integrity in your
table relationships. recommend you do that immediately.
--- "Bob Bridges" <rh*****@attglo bal.netwrote in message
news:45e90dd7$1 @kcnews01...
>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...whic h 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 records AND THE PARENT record are
deleted -- definitely not what I wanted.

I have another query that could be described the same way, except in that
form when I delete a record only the child record is deleted from the
original tables. It doesn't seem to make any difference whether the join
is inner or outer, nor whether parent data is displayed in the detail
section.

So here's the question: What determines the outcome? How do I write the
query, and/or design the form, to be sure that when I want to delete a
child record in the form, the parent record will survive? Are the rules
for
this documented somewhere?

Mar 3 '07 #3
On Sat, 3 Mar 2007 12:12:29 -0600, "Bob Bridges"
<rh*****@attglo bal.netwrote:

It's tricky to delete rows using a query with a join. Just put
yourself in the position of the query processor. What are you supposed
to do?
Much better to use one on a single table. That's what most samples
(e.g. Northwind) show you.
I've never seen the rules you're looking for documented anywhere. If
you come up with some, please post back. In the meantime I would try
to redesign (e.g. with a parent form on the One table, and a details
subform on the Many table) to avoid the issue altogether.

-Tom.

>Message received, but that's not my question. Hear it again, please: I
have a query with joined records, and when I hit the <Delkey while viewing
that data in a form I want it to delete just the child record, not the
parent. It works that way in one form but not another, and I haven't yet
been able to figure out what the difference is between the two so that I can
control it. Anyone know what makes that determination.

--- "tina" <no****@address .comwrote in message
news:t2******* ***********@bgt nsc05-news.ops.worldn et.att.net...
>if you are able to delete a parent record and leave *any* of its' child
records intact, then you haven't enforced referential integrity in your
table relationships. recommend you do that immediately.
>--- "Bob Bridges" <rh*****@attglo bal.netwrote in message
news:45e90dd7$ 1@kcnews01...
>>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...whi ch 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 records AND THE PARENT record are
deleted -- definitely not what I wanted.

I have another query that could be described the same way, except in that
form when I delete a record only the child record is deleted from the
original tables. It doesn't seem to make any difference whether the join
is inner or outer, nor whether parent data is displayed in the detail
section.

So here's the question: What determines the outcome? How do I write the
query, and/or design the form, to be sure that when I want to delete a
child record in the form, the parent record will survive? Are the rules
for
this documented somewhere?
Mar 3 '07 #4
Now this I can believe. I perfectly understand your point about seeing it
from the query processor's point of view. "Great!", I think, "Good advice;
I'll rewrite it to display...um... ."

Then I pause uncertainly. How DO I display data from multiple tables
without using a query joining two tables? If you're really saying simply
that my child form must not display any datum showing which parent it refers
to, I'm afraid that's out of court from the beginning. But I don't really
believe it's what you meant; you must have in mind something else, a
workaround that hasn't occurred to me.

So here's what I want my form to display, sort of:

Header section:
5047 Baxter Corp
5058 Tom Remak
Detail section:
Baxter Corp Fax number
Baxter Corp URL
Tom Remak Office phone
Tom Remak Email address
Tom Remak Cell phone

If you're saying I shouldn't display "Baxter Corp" or "Tom Remak" next to
the individual child records to identify whose they are, that's no good to
me and anyway I don't believe it -- that is, I can't believe MS would create
a product incapable of handling a situation that must be very common. But
if you're saying there's a way to structure the query and/or form so that
Access needn't be confused about which records to go after when I delete one
of the items in the above detail section, I'm all for it...but how do I feed
mixed data to this form without using a JOIN?

And meanwhile, as you suggest, if I figure it out for myself before one of
you bright folks clues me in, I definitely will post my solution. Thanks.

---
Bob Bridges, rh*****@attglob al.net, cell 336 382-7313
(hotel) 612 869-7704 xt 118, fax 612 869-7383

/* A crooked politician may be faithful to his wife, but a man who deceives
his own wife can't be relied on to deal honestly with the public. We have
been getting this backward lately. We've been assuming that you can have
public virtue without private virtue. -Joseph Sobran, 1998 */

--- "Tom van Stiphout" <no************ *@cox.netwrote in message
news:h1******** *************** *********@4ax.c om...
It's tricky to delete rows using a query with a join. Just put
yourself in the position of the query processor. What are you supposed
to do?
Much better to use one on a single table. That's what most samples
(e.g. Northwind) show you.
I've never seen the rules you're looking for documented anywhere. If
you come up with some, please post back. In the meantime I would try
to redesign (e.g. with a parent form on the One table, and a details
subform on the Many table) to avoid the issue altogether.
>>--- "Bob Bridges" <rh*****@attglo bal.netwrote in message
news:45e90dd7 $1@kcnews01...
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...whic h 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 records AND THE PARENT record
are
deleted -- definitely not what I wanted.

I have another query that could be described the same way, except in
that
form when I delete a record only the child record is deleted from the
original tables. It doesn't seem to make any difference whether the
join
is inner or outer, nor whether parent data is displayed in the detail
section.

So here's the question: What determines the outcome? How do I write
the
query, and/or design the form, to be sure that when I want to delete a
child record in the form, the parent record will survive? Are the
rules
for this documented somewhere?

Mar 6 '07 #5
One work around to try.

Cancel the delete in the OnDelete event of the form, then delete the child
record with an action query.

"Bob Bridges" <rh*****@attglo bal.netwrote in message
news:45e90dd7$1 @kcnews01...
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 records AND THE PARENT record are
deleted -- definitely not what I wanted.

I have another query that could be described the same way, except in that
form when I delete a record only the child record is deleted from the
original tables. It doesn't seem to make any difference whether the join
is
inner or outer, nor whether parent data is displayed in the detail
section.
>
So here's the question: What determines the outcome? How do I write the
query, and/or design the form, to be sure that when I want to delete a
child
record in the form, the parent record will survive? Are the rules for
this
documented somewhere?

---
Bob Bridges, rh*****@attglob al.net, cell 336 382-7313
(hotel) 612 869-7704 xt 118, fax 612 869-7383

/* A crooked politician may be faithful to his wife, but a man who
deceives
his own wife can't be relied on to deal honestly with the public. We have
been getting this backward lately. We've been assuming that you can have
public virtue without private virtue. -Joseph Sobran, 1998 */


Mar 7 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2448
by: Marek Lewczuk | last post by:
Hello, I have a strange problem, maybe some of you will be able to explain me something. I use LEFT JOIN as a substitute for subselects. It's true that many subselects can be rewriten using LEFT JOIN. I have made a query which use LEFT JOIN statement and... when there are many LEFT JOIN's (over 3) on the same table MySQL execute this query very long time... few hours or more. Maybe there is something wrong with my table structures... Are...
5
1326
by: (Pete Cresswell) | last post by:
Seems to me like I've done this. When it wasn't possible to delete the records in question via a fairly complicated query I resorted to creating a work table containing IDs of recs TB deleted, then did the deletes by joining the target table to the work table. I'm trying to do that right now and an error's popping to the effect the delete cannot be done. Anybody know the rules? --
9
18559
by: Mike Bridge | last post by:
I am using MS Access 2003, and I typed in a query in SQL view which was working fine. Now when I open it, it gives me the error "Join expression not supported". Apparently, Access "fixed" it for me. Unfortunately, I can't correct it because when I click "OK", the window disappears. I don't see any way to open the query directly in SQL view, and both the Design and Data views exit as soon as I close the error dialog. Is there any way...
5
4043
by: jason.evans | last post by:
Hi there. I am having an intrigueing problem. I have a query which left joins another query to itself twice. The original query is derived from a linked table in SQLServer 2000. When I run it on my pc It runs fine. However for other users in the office, it behaves as an inner join. ie it only returns the records fo which the join fields equal each other. This happens on every other pc
9
20106
by: deko | last post by:
I need to create a Recordset of all records that appear in one table but do NOT appear in another. To get the records that appear in BOTH tables, I can do this: SELECT tblEntity.Entity_ID FROM tblEntity INNER JOIN tblDocuments ON tblEntity.Entity_ID = tblDocuments.Entity_ID;
14
5716
by: mike | last post by:
I'm using postgresl 7.3.2 and have a query that executes very slowly. There are 2 tables: Item and LogEvent. ItemID (an int4) is the primary key of Item, and is also a field in LogEvent. Some ItemIDs in LogEvent do not correspond to ItemIDs in Item, and periodically we need to purge the non-matching ItemIDs from LogEvent. The query is: delete from LogEvent where EventType != 'i' and ItemID in
52
6330
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the distinct groups
2
2629
theGeek
by: theGeek | last post by:
I always wonder which one of join or subquery should I be using to solve a particuar problem so that I get the correct result set in minimum time. It usually happens that I can write a query quickly using subqueries (I think I happen to think that way more easily than join way :)) but I see others making use of joins all the time. May be that they can think of a query more easily using joins. I am saying that because I don't usually see much of...
1
3292
by: Nettle | last post by:
Purpose: This is a Distribution List database. Function: Users create many different email distribution lists, tailoring each to fit their specific needs Wanted: Users can combine multiple distribution lists to create new ones. Sometimes, however, they discover they've made a mistake. Users would like to delete from a new distribution list only the records that belong to an old one. Technique (Short)
0
8840
marktang
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...
0
8730
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,...
0
9367
Oralloy
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...
0
9215
jinu1996
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...
1
9131
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,...
0
9064
tracyyun
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...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2130
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.