Tips for mysql-implement split truncation without writing a function _ MySQL

Source: Internet
Author: User
Tips for mysql-implement split to intercept bitsCN.com without writing a function

Tips for mysql-implement split truncation without writing a function

1. implement split truncation without writing a function

Scenario: dayNewStat + meilishuo + ipad + 2003 (dayNewStat + meilishuo + iphone + 2003) (dayNewStat + meilishuo + android + 2003)

Imagine: split ('+') [-1] (written in python)

Implementation: there are strict format requirements, clever methods, no technical content

1substring(record_tag,locate('+',replace(record_tag,'dayNewStat+meilishuo+',' dayNewStat-meilishuo-')))2. having + min + if

Scenario: as long as the status is OK and the id is the smallest

id      type     status001    aaa      ok002    aaa      error010    aaa      ok003    bbb     ok

Implementation: deduplication & conditional filtering

1select stat_date,record_tag,substring(record_tag,locate('+',replace(record_tag,'dayNewStat+meilishuo+',' dayNewStat-meilishuo-'))) as client_id,attr_value2from t_stat_daynew_classify_2013063where  record_type='dayNewStat+app+device+clientID' and record_tag like 'dayNewStat+meilishuo+%'  and attr_name ='totalDID' and attr_name_hash = 1380872519 and record_type_hash = 20394970044group by stat_date,record_tag5having min(id) and if( (client_id>10000 and record_tag like 'dayNewStat+meilishuo+android%') or (client_id>2000 and client_id<5000 and record_tag like 'dayNewStat+meilishuo+ipad%')  or (client_id>5000 and client_id<10000),'ok','del' ) = 'ok' order by stat_date,client_id


BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.