Oracle implements find_in_set sorting for mysql!

Source: Internet
Author: User

Oracle implements find_in_set sorting for mysql!

Oracle implements sorting similar to MYSQL find_in_set, function decode:

Select * from tb_info_game where gameid in (, 18) order by decode (gameid)
By default7 # zbphp.com

Reference CDSN post: http://topic.csdn.net/t/20060124/08/4532718.html

Question:
Bytes ------------------------------------------------------------------------------------
SQL statement

Order by can be sorted by specified order No

For example, the value of a field in the record nch hch acs twn ....

I want records to be arranged in the above Order. OK?

Answer:
Bytes -------------------------------------------------------------------------------------
Order by decode (col, 'nch ', '1', 'hch', '2', 'acs', '3', 'twn', '4', col)

This is the case.

Note:
"Col" indicates the name of the column to be sorted.
'Nch', 'hch', 'acs', and so on indicate specific data in the sorted column.
"1", "2", "3", and so on indicate the specified sequence of the corresponding data.

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.