Question

I'm looking for operator that can wrap a SELECT expression that behave like LIKE operation (but instead of using it on WHERE clause, use it on SELECT expression) and will return that expression. Something that could operate like this:

SELECT LEFT(MutationGRCh37,1)
FROM mutationschema.cosmicmutations WHERE MutationGRCh37 LIKE '_:%'

But instead of using left and like, use some sort of composition of the two, like:

SELECT LIKE(MutationGRCh37,'_:%')
FROM mutationschema.cosmicmutations

This a simple example, but with more complex partial matching I need to use a lot of mathematical abstraction to handle this given just the string operations in here: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html

Was it helpful?

Solution

If you want to get everything before the colon, you can use substring_index():

select substring_index(MutationGRCh37, ':', 1)
. . .

So, if the column contains 'abc:123', then this will return 'abc'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top