Delete row if table exists SQL
For SQL Server: You could use:
IF OBJECT_ID('tablename','U') IS NOT NULL
This one deletes the row and does not complain if it can't.
DELETE IGNORE FROM table WHERE id=1
source here.
To check in SQL SERVER,
IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'TheSchema' AND TABLE_NAME = 'TheTable'))
BEGIN
--Do Stuff
END
To check in mysql:
You simply count:
SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = '[database name]'
AND table_name = '[table name]';