Last active
June 28, 2017 10:49
-
-
Save PierreLebedel/09ab7545d63b6db8e7db974a3de94d7f to your computer and use it in GitHub Desktop.
MySQL select rows where field contains X occurences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, ROUND( | |
( LENGTH(field) - LENGTH( REPLACE(field, "search", "") ) ) / LENGTH("search") | |
) AS count | |
FROM table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment