I want a query (in msyql) to get records with same character 3 times:
aa => false
aaa => true
baaa => true
aaab => true
aaaaaab => true
baaab => true
babababa => false
For any character, not only 'a' and 'b'.
The following sentence doesn't work:
SELECT field1
FROM mytable
WHERE field1 REGEXP '(.)\1\1';
It could be this using the SUBSTR function in MySQL: SELECT `name` FROM `students` WHERE `marks` > 75 ORDER BY SUBSTR(`name`, -3), ID ASC; SUBSTR(name, -3) will select the last three characters in the name column of the student table.
MySQL supports another type of pattern matching operation based on the regular expressions and the REGEXP operator. It provide a powerful and flexible pattern match that can help us implement power search utilities for our database systems.
SELECT COUNT(email) as count FROM table1 t1 JOIN ( SELECT company_domains as emailext FROM table2 WHERE company = 'DELL' ) t2 ON t1. email LIKE CONCAT('%', emailext) WHERE t1. event='PC Global Conference"; Task was count participants at an event(s) with filter if email extension equal to multiple company domains.
May be this can help you.
select * from test1 where name REGEXP '[a]{3}|[b]{3}|[c]{3}|[d]{3}|[e]{3}|[f]{3}|[g]{3}|[h]{3}|[i]{3}|[j]{3}|[k]{3}|[l]{3}|[m]{3}|[n]{3}|[o]{3}|[p]{3}|[q]{3}|[r]{3}|[s]{3}|[t]{3}|[u]{3}|[v]{3}|[w]{3}|[x]{3}|[y]{3}|[z]{3}';
It returns records for 3 same and consecutive letters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With