473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

MLH
I had a table (tblReturnReceipts) 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 tblReturnReceipts.RtnRcptID, tblReturnReceipts.CorrespID,
tblReturnReceipts.DateSigned, tblReturnReceipts.OLA,
tblReturnReceipts.OLA_ID, tblReturnReceipts.RRTDstamp,
tblReturnReceipts.RRuser, tblReturnReceipts.Tracked FROM BadRRIDs
INNER JOIN tblReturnReceipts ON BadRRIDs.RRID =
tblReturnReceipts.RtnRcptID;

I wanted to run the query, which lists all the records in
tblReturnReceipts 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 1287
On Fri, 17 Mar 2006 14:52:58 -0500, MLH <CR**@NorthState.net> wrote:

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

-Tom.

I had a table (tblReturnReceipts) 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 tblReturnReceipts.RtnRcptID, tblReturnReceipts.CorrespID,
tblReturnReceipts.DateSigned, tblReturnReceipts.OLA,
tblReturnReceipts.OLA_ID, tblReturnReceipts.RRTDstamp,
tblReturnReceipts.RRuser, tblReturnReceipts.Tracked FROM BadRRIDs
INNER JOIN tblReturnReceipts ON BadRRIDs.RRID =
tblReturnReceipts.RtnRcptID;

I wanted to run the query, which lists all the records in
tblReturnReceipts 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 tblReturnReceipts.RtnRcptID, *
FROM tblReturnReceipts
WHERE tblReturnReceipts.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
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...
1
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...
2
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...
0
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...
11
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...
2
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); ...
0
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...
6
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...
0
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...

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.