Certainly. You simply need to construct a query, and at that point you have a few options. One way is to do a count() query and only proceed if the count is > 0. The other is to issue the query, and use the client library feature to determine if there are results.
The specifics require a bit more information in regards to the database and client library you are utilizing in your code, not to mention the schema (table structure(s)) and the query(s) you are using.
For something as simple as finding a coupon row by some sort of id string, I would probably opt for the 2nd option, and run the query and check for a result.
Then your code checks that result set count with an if() and proceeds to fetch the row, or prints out your error/coupon not found message if not.
Just taking a wild guess that you might be using MySQL:
With mysqli
With PDO it is typically best to just query and fetch the data (as this should be either one row or none) and then check the result variable
$data = $pdo->query("SELECT * FROM table WHERE ...")->fetchAll();
if ($data) {
// There's a coupon
} else {
// There is no coupon
}
It's actually more complicated than that, because you should be using prepare to bind the variable and execute, but the basic idea is the same.