in reply to Re^2: cleaning up dbi code
in thread cleaning up dbi code

You don't need a full inner join. Maybe try:

delete from a where a.col1 in (select distinct col1 from b)

But what I wonder about in your SQL is why you have two references to the same table tbl. Do you really want to delete the whole table?

Replies are listed 'Best First'.
Re^4: cleaning up dbi code
by Anonymous Monk on Nov 26, 2010 at 19:49 UTC
    why does it delete the whole table? I ran it earlier and it didn't delete the whole table? doesn't it just delete the rows that satisfy the join?
      delete b.* from tbl a inner join tbl b on a.col1 = b.col1

      This looks like a self-join of the table with itself to me. But if your posted SQL was just sample code, maybe you should work more on workable samples you post. If not, consider thinking more about what you really want to do.

      One standard practice I have when using rm or delete is to run ls respectively select first, and look at the output, and think long and hard about whether the output I see is the stuff I want deleted. Only then I change the select into a delete.

      I'd guess that the rows you have left contain a null in that column, since null doesn't equal null (in the databases I use).

      ...roboticus