473,938 Members | 5,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to indicate which table's records get deleted in a 2-table query.

MLH
I had a table (tblReturnRecei pts) with 47 records and I wanted 18
of its records deleted. So I thought I would be smart and make
another table (a temporary junk table) named BadRRIDs and use
it in the following Select query...

SELECT tblReturnReceip ts.RtnRcptID, tblReturnReceip ts.CorrespID,
tblReturnReceip ts.DateSigned, tblReturnReceip ts.OLA,
tblReturnReceip ts.OLA_ID, tblReturnReceip ts.RRTDstamp,
tblReturnReceip ts.RRuser, tblReturnReceip ts.Tracked FROM BadRRIDs
INNER JOIN tblReturnReceip ts ON BadRRIDs.RRID =
tblReturnReceip ts.RtnRcptID;

I wanted to run the query, which lists all the records in
tblReturnReceip ts targeted for deletion, select all the rows
with the mouse and press the delete key. For the life of me,
I can only delete the 18 records in the trash table - BadRRIDs.

How do I tell the query to delete the records in the OTHER table?
Mar 17 '06 #1
2 1307
On Fri, 17 Mar 2006 14:52:58 -0500, MLH <CR**@NorthStat e.net> wrote:

Delete * from MainTable
where ID in (select ID from BadTable)

-Tom.

I had a table (tblReturnRecei pts) with 47 records and I wanted 18
of its records deleted. So I thought I would be smart and make
another table (a temporary junk table) named BadRRIDs and use
it in the following Select query...

SELECT tblReturnReceip ts.RtnRcptID, tblReturnReceip ts.CorrespID,
tblReturnRecei pts.DateSigned, tblReturnReceip ts.OLA,
tblReturnRecei pts.OLA_ID, tblReturnReceip ts.RRTDstamp,
tblReturnRecei pts.RRuser, tblReturnReceip ts.Tracked FROM BadRRIDs
INNER JOIN tblReturnReceip ts ON BadRRIDs.RRID =
tblReturnRecei pts.RtnRcptID;

I wanted to run the query, which lists all the records in
tblReturnRecei pts targeted for deletion, select all the rows
with the mouse and press the delete key. For the life of me,
I can only delete the 18 records in the trash table - BadRRIDs.

How do I tell the query to delete the records in the OTHER table?


Mar 18 '06 #2
MLH
Thx, Tom.

DELETE tblReturnReceip ts.RtnRcptID, *
FROM tblReturnReceip ts
WHERE tblReturnReceip ts.RtnRcptID In (select RRID from BadRRIDs);

worked perfectly.
Mar 18 '06 #3

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

Similar topics

27
2174
by: Alex | last post by:
Hi, MySQL has a nice feature that allows to call a replace rather insert which will attempt to insert if record not present and replace if it does. Is there any similar feature ? Currently I run a select prior to any insert and then update or insert depending on the result of the select. The problem here is that I just doubled the queries. Doing so on a table with 5Mio rows and on 100k inserts will take time and I would like to have...
1
1577
by: Matt | last post by:
I have a project where I need to have navigation buttons. Now I got them working but I found a problem that occurs when there are records deleted from the DB. The DB I am accessing has an ID column that is the primary key and uses AutoNumber. My program also allows the user to delete records. My problem occurs when someone deletes a record other than the first or last record in the DB. The way my Next navigation button works is that it...
2
1509
by: Nathan Bloom | last post by:
Hi, I understand that when a record is deleted it is still in the database but just flagged as deleted. Is there anyway to recover these deleted records? I am using Access 2000. Any help in this would be greatly appreciated and Thanks in advance for any help given. Nathan Bloom
0
309
by: maddman | last post by:
I have an odd problem with my database, and was hoping someone could point me at the problem. We have an access database that is used by several people to input data. Users have reported some of the records in their forms (Datasheet view) are showing up as "#Deleted", though no one should be deleting records from here. Further, the messages show up only on certain users' screens. Is this a result of corruption from having multiple...
11
37053
by: serge | last post by:
When i debug a trigger is it possible to add a WATCH on the INSERTED or DELETED? I think not, at least I couldn't figure out a way to do so. Does someone have a suggestion on how I can see the values? I did try to do something like INSERT INTO TABLE1(NAME) SELECT NAME FROM INSERTED
2
3323
by: naughtybynature | last post by:
<?php $db = mysql_connect("localhost", "root",""); mysql_select_db("sistem bank soalan",$db); $result = mysql_query("SELECT * FROM soalan",$db); $count_emp=mysql_num_rows($result); if ($count_emp==0) $id=1; else
0
1362
by: sherifffruitfly | last post by:
Hi, I'm deleting a bunch of records from my DB, and they actually DO get deleted (as I verify by looking afterwards). But then I get the exception in the subject line. Isn't it weird that all of the correct records would get deleted, and only *after* that, an error gets thrown? Here's the code I'm using - thanks for any ideas! try
6
6327
by: jcf378 | last post by:
hello-- i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the Excel file, rather than completely overwriting it (as occurs with the basic OutputTo function). specifically, I am trying to create a macro that "backs-up" any deleted record. So, when someone goes to delete a record (i have a delete-record macro...
0
2187
by: remya1000 | last post by:
I need to display current month,last 3months,6months and 1year records seperatly. and first i'm tring to display current month's records. and the error i received is this. Microsoft VBScript compilation error '800a0401' Expected end of statement /admin/currentmonth.asp, line 26 strSQL = "SELECT RFCInfo.Name, RFCInfo.Date, RFCInfo.RFCNo, RFCInfo.InvNo, RFCInfo.Deleted, InvoiceDetail.Quantity, InvoiceDetail.Description,...
1
1605
by: MostBanyest | last post by:
i am not good in programming and i need help i wrote a program in VB6 that uses MS access database, its supposed to save records into a temporary database, when you are happy with the records it copies them to a permanent database, then deletes all contents in the temporary database in order to enter new records, this process is repeated over and over again but, sometimes very fast, when i checked the permanent database i have noticed that i...
0
10133
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
9963
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
11521
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
10653
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
9854
agi2029
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...
1
8216
isladogs
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...
0
7379
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
6292
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3498
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.