For the two sentences of "or" SQL ", how does the ike sort data by the like sequence?

Source: Internet
Author: User
For the two sentences of "or" SQL ", how does the ike sort data by the like sequence? Name LIKE "% A %" OR time LIKE "% B %"

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


Reply to discussion (solution)

... Order by if (instr (name, 'A')> 0, 0) desc

... Order by if (instr (name, 'A')> 0, 0) desc
Do you have a full sentence example? I cannot understand such a sentence!

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

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

The actual arrangement result I want is probably the following statement, which sorts the data in two parentheses in sequence, first in the first bracket, in the row of 2nd brackets ....

SELECT * from cs where (time like "" % a % or name like "% B %" or time like "% e % ") or (time like "" % 11% or name like "% 22%" or time like "% 33% ")

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.