I am trying to create a unique slug (while adding new data) and update slug (while updating existing data).
I want to have a mySQL query like:-
"SELECT COUNT(*) FROM cms WHERE (slug = '$slug' OR slug LIKE '$slug-{{numeric-value}}%'"
The idea is, slug = '$slug' will check whether an exact match exists and slug LIKE '$slug-{{numeric-value}}%' will check whether slugs like about-us-2, about-us-3 exists. However, about-us-more will treated as be a different slug.
How can I create the accurate mySQL query?