Continue high Score

Source: Internet
Author: User
Continue high scores for help.
The requirements are as follows:
The existing call field in the table caller
State field Status

When the foreground is displayed, if status = Paid view
The caller phone number is displayed as 1331234**** (after 4 bits hidden)

Call logs have a search function.
Where caller supports fuzzy search

Now, if there are two numbers,
13356781234 and 1331234**** (* * * * = 5678, only the template is displayed as * * *, the database is 13312345678)
Ask me how to determine the status = Paid view when searching for a blur of 5678
Only the first one, not the second one.

SQL Code
select * from table where table.column like '%5678% ' and status = ' paid view ' 
------ Solution--------------------
Search only the first 7 bits, where left (caller,7) like '%...% '
WHERE ( Status = ' pay View ' && left (caller,7) ' OR ' (Status! = ' pay to see ' caller like '%...% ')

What does that mean?
appears only at the end of like '%5678 '
only appears at the beginning of the like ' 133% '

MySQL has regular expressions, you can use

Your requirements are not very clear.
above () use and only for
can't be flexible.

SUBSTR (field, 1, LENGTH (field)-4) Like '%......% '

As for whether or not to pay, it is you control SQL statements in PHP code
------ Solution--------------------
Left function Oh, get the field length, minus the back 4 bits

You are all numbers here, length is OK
------ Solution--------------------
Amani11 That's OK
isn't that right?

WHERE (status = ' Paid View ' and SUBSTR (field, 1, LENGTH (field)-4) OR (Status! = ' paid view ' and caller Like '%...% ')

  • Related Article

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