JEMaddux
JEMaddux

Reputation: 303

SQL find the count of a table that has an attribute containing a string

I have a table called delayed_jobs that has a column last_error. I want to get the count of rows that has the string "duplicate key" in the last_error attribute. So far I have gotten:

select count(1)
from delayed_jobs

Which returns:

6880

The number should be closer to 100.

Upvotes: 1

Views: 26

Answers (1)

JEMaddux
JEMaddux

Reputation: 303

Found it! It should be:

select count(1)
from delayed_jobs
where last_error like '%duplicate key%'

Which returns 68

Upvotes: 2

Related Questions