Trying to use SQL Script to clear specific data from a table.
Posted on 2006-05-31
I have a need to clear data from one table. However in order to clear the data, I need to run a query against another table to determine what needs to be deleted.
I use the following to get the data I want to delete:
select * from crpdta.f06502, crpdta.f060116 where yean8=yaan8 and yahmco='01000';
crpdta is the container (this is actually on an AS400)
f06502 is the table I want to delete Data out of
f060116 is the table I cross reference with to find the data I need to delete
I've tried various delete statements, but have been unsucessful so far.
**** UPDATE ****
Working with a couple of people in MySQL, we've gotten close...
DELETE FROM crpdta.f06502 WHERE EXISTS(select * from crpdta.f06502, crpdta.f060116 where yean8=yaan8 and yahmco='01000');
It clears the whole file however. But it got further than i have been previously.
Another option, would be to update a column with a "tagged" number, so that i can then run a delete based on this new #...
Hoping someone can assist.