Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

According to the documentation, the IGNORE option will treat errors as warnings.

DELETE IGNORE ...

The IGNORE keyword causes MySQL to ignore all errors during the
process of deleting rows. (Errors encountered during the parsing stage
are processed in the usual manner.) Errors that are ignored due to the
use of IGNORE are returned as warnings.

I'm not sure whether MySQL would treat a non-existent table as "an error in the parsing stage". If it does, you can query the information_schema for a table name. Something along these lines should work.

Thanks a lot for the quick response. I tried using IGNORE to no avail, I guess the non-existent table is found during the parsing stage. How would I construct the SELECT and DELETE as one query? From what I understand I can't use IF statements because MySQL only supports them as stored procedures.
–
GTEOct 9 '11 at 20:14

2

You can't do it in a single statement. Why don't you want to handle the error in Ruby? (It doesn't make sense to not handle errors in Ruby.)
–
Mike Sherrill 'Cat Recall'Oct 9 '11 at 22:32