If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > delete statement over 2 tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-01-03, 06:12
poekel poekel is offline
Registered User
 
Join Date: Nov 2003
Location: DE
Posts: 6
delete statement over 2 tables

hello,

my problem is to delete some rows in a table by joining another table:

DELETE FROM
tableA
WHERE
tableA.rowA='1'
AND
tableB.rowB=tableA.rowA;

this produces errors:

SQL0206 "SCHEMA.TABLE.ROW" is not a valid in this context SQLSTATE 42703
Database is DB2 8.1.4 on NT

where is this error come from? i think its not possible to join another tables in a delete statement...is this right?

thank you!

poekel
Reply With Quote
  #2 (permalink)  
Old 12-01-03, 06:39
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,

Try to write subselect, something like:

DELETE FROM
tableA
WHERE
rowA='1'
AND
rowA in (select rowB from tableB);

Hope this helps,
Grofaty

Last edited by grofaty; 12-01-03 at 06:42.
Reply With Quote
  #3 (permalink)  
Old 12-01-03, 07:00
poekel poekel is offline
Registered User
 
Join Date: Nov 2003
Location: DE
Posts: 6
ok thanx, i try this...

poekel
Reply With Quote
  #4 (permalink)  
Old 12-01-03, 07:23
poekel poekel is offline
Registered User
 
Join Date: Nov 2003
Location: DE
Posts: 6
yes it works!

thanx again...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On