Or two sentences of SQL, how does ike sort data by like

Source: Internet
Author: User
For the two sentences of "or" SQL ", how does the ike sort data by the like sequence? Name & nbsp; LIKE & nbsp; % A % & nbsp; OR & nbsp; time & nbsp; LIKE & nbsp; % B % how to finish like & nbsp; result of A & nbsp; in the row & nbsp; result of B? ------ Solution ---------- How does ike of the two SQL statements of "or" sort data by "like?
Name LIKE "% A %" OR time LIKE "% B %"

How can I finish the result of like A in B?


------ Solution --------------------
... Order by if (instr (name, 'A')> 0, 0) desc
------ Solution --------------------
This half sentence is understandable.
That is to say, convert the string containing 'a' to 0, 1, and sort the string by 01. the string contains 1, and the string that does not contain 0.
The final sorting is order by if (instr (name, 'A')>, 0) desc
------ Solution --------------------
The same. I used the same statement in the preceding statement. I can't even understand it?
Order by if (instr (name, 'A')> 0, 1, (if (instr (name, 'B')> 0, 1, (if (instr (name, 'E')> 0, 1) desc

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.