Problem with% (percent semicolon) after using like in MySQL statement

Source: Internet
Author: User

Problem: MySQL statement using the% (percent semicolon) after like is not the more efficient the slower it runs!

Total Time: 0.0489 sec 0.0691 0.0485 0.0467

SELECT ' Goods_name ', ' goods_img ', ' sku_id ', ' import ' from ' goods ' WHERE ' goods_name ' like '%iphone%ipod% ' and ' stime ' < 1413877244 and ' etime ' > 1413877244 ORDER by ' flag ' DESC


Total Time: 0.0460 sec 0.0430 0.0493 0.0783 0.0496

SELECT ' Goods_name ', ' goods_img ', ' sku_id ', ' import ' from ' goods ' WHERE ' goods_name ' like '%iphone% ' and ' goods_name ' like '%ipod% ' and ' stime ' < 1413877367 and ' etime ' > 1413877367 ORDER by ' flag ' DESC

total time: 0.0458 seconds 0.0441 seconds 0.0449 seconds

SELECT ' Goods_name ', ' goods_img ', ' sku_id ', ' import ' from ' goods ' WHERE ' goods_name ' like '%%%%%%%%%%%%%%%%%%%%%%%iphone %ipod%%%%%%%%%%%%%%%%%%%%%%% ' and ' stime ' < 1413877997 and ' etime ' > 1413877997 ORDER by ' flag ' DESC

Practice has shown that the number of percent semicolons does not affect the speed of SQL operations. These methods are almost identical in efficiency.

These are the results of my test. Individuals can choose the writing according to their actual needs! advice is best to choose another one!

Problem with% (percent semicolon) after using like in MySQL statement

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