MySqllike query conversion method (like query is not required) _ MySQL

Source: Internet
Author: User
MySqllike query conversion method (like query is not required) bitsCN.com
Select * from account where userName like 'AD % '; select * from account where userName> = 'AD' and userName <' AE'

The results of these two queries are the same, and the efficiency seems to be similar. no specific efficiency test is conducted. if you are interested, you can test the efficiency.

In the like query, ad % is the data of userName starting with ad,

UserName> = 'ad' is used to query data starting with ad and also contains AE, af, ag ......, That is, to query data where "ad" contains d and is greater than d in "ad"

Therefore, and userName <'ad' ensures that the query interval is in "ad", while AE, af, ag ...... This data will not appear in the result set.

Of course, you can try:

Select * from account where userName> = 'AD' and userName <'Az ';

Does the result set contain: AE, af, ag ...... Ak, al ...... Data starting with ay and az.

Author: hoojo
Source:
Blog: http://blog.csdn.net/IBM_hoojo
The copyright of this article is shared by the author and the blog Park. You are welcome to repost this article. However, you must retain this statement without the author's consent and provide a clear link to the original article on the article page. Otherwise, you will be held legally liable.


All rights reserved. For more information, see the source. This article is from:
All rights reserved. You are welcome to reprint it. please indicate the source for reprinting. thank you, 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.