Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with delete from table

Status
Not open for further replies.

rtrujill

MIS
Nov 16, 2004
6
US
Hopefully someone can help me.

I need to delete some data from a table by referencing 2 other table.

Table A is the table I need to delete rows from but does not have all the data I need to determine if I need to delete the row. I have created a view that will give me all the columns from Table A and a column from Table B.

Table C Is the table the will determine on whether or not I will delete data from Table A. Below is the delete function that I ran. When I run the sql statement it show that 4 rows are deleted but the rows do not delete. Below is the sql statement. The vw_aphldinv_final is the view that I created. Thanks in advance!

Delete from aphldinv
Where exists
(select *
from vw_aphldinv_final
where aphldinv.vendor_group = vw_aphldinv_final.vendor_group
and aphldinv.hld_code = vw_aphldinv_final.hld_code
and aphldinv.company = vw_aphldinv_final.company
and aphldinv.vendor = vw_aphldinv_final.vendor
and aphldinv.invoice = vw_aphldinv_final.invoice
and aphldinv.suffix = vw_aphldinv_final.suffix
and aphldinv.cancel_seq = vw_aphldinv_final.cancel_seq
and aphldinv.seq_nbr = vw_aphldinv_final.seq_nbr
and aphldinv.void_seq = vw_aphldinv_final.void_seq)
 
Hopefully aphldinv has a Primary Key:
DELETE FROM aphldinv
WHERE PK column IN (SELECT PK column FROM vw_aphldinv_final)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top