How to fix "cannot drop database 'x'; database doesn't exist" in sql?

Example:

DROP DATABASE nonExistentDB;
This error message appears when you’re trying to drop a database that doesn’t exist.

Solution:

-- Ensure you’re using the correct database name or check if the database exists before attempting to drop it.

Beginner's Guide to SQL