문제

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

도움이 되었습니까?

해결책

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'.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top