To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Related Sites > SQL Course

SQL Course SQL Course > Ask questions about the lessons on SQL Course 1 and 2. If you have problems > with the interface, please post in the Feedback forum

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 12-30-2002, 11:27 AM
mrvy1 mrvy1 is offline
Junior Member
 
Join Date: Oct 2002
Posts: 5
can one delete records based on a join?

One would think that this would be a fairly common task. If there are any records in Table A whose id is on the "kill list" (Table B), delete that record.

So, for example:

DELETE *
FROM Table_A
WHERE Table_A.ID = Table_B_List_of_bogus_records.ID;

I'm attempting this query on Access, so it may not be a SQL problem. Access views "Table_B_List_of_bogus_records.ID" as a parameter needing input.

Any ideas?

Much appreciated.
Reply With Quote
  #2  
Old 12-30-2002, 01:40 PM
skhanal skhanal is offline
Experts
 
Join Date: Nov 2002
Location: New Jersey, USA
Posts: 3,369
Have you tried this

DELETE Table_A
FROM Table_A, Table_B_List_of_bogus_records
WHERE Table_A.ID = Table_B_List_of_bogus_records.ID;
Reply With Quote
  #3  
Old 12-30-2002, 01:50 PM
mrvy1 mrvy1 is offline
Junior Member
 
Join Date: Oct 2002
Posts: 5
still doesn't work...

skhanal,

I get a message saying:

"cannot find file <path to my database>\Table_B_List_of_bogus_records"

I don't get it...

But thanks for the suggestion anyway.

---Michael
Reply With Quote
  #4  
Old 12-30-2002, 02:22 PM
mrvy1 mrvy1 is offline
Junior Member
 
Join Date: Oct 2002
Posts: 5
it works...

I've got it to work after all. I tried this query:

DELETE Table_A.*
FROM Table_A
INNER JOIN Table_B_List_of_bogus_records ON Table_A.ID = Table_B_List_of_bogus_records.ID ;

Seems rather convoluted IMHO, but it works.

Thanks!
Reply With Quote
  #5  
Old 12-30-2002, 04:49 PM
skhanal skhanal is offline
Experts
 
Join Date: Nov 2002
Location: New Jersey, USA
Posts: 3,369
Oh ya, Access does not recognize the syntax I wrote, it had to be ANSI.
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:13 AM.


DatabaseJournal Recent Articles


 » Preparing To Upgrade Access Tables to SQL ...

 » Microsoft Windows PowerShell and SQL Serve...

 » New MySQL Enterprise with Query Analyzer B...

 » Quest Software Strengthens Committment to ...

 » Oracle Unveils New Event-Driven Middleware...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.