Oracle implements find_in_set sorting for mysql !, Oraclefind_in_set
Oracle implements sorting similar to MYSQL find_in_set, function decode:
select * from tb_info_game where gameid in(23,20,19,26,18) order by decode(gameid,23,1,20,2,18,3,26,4,1009,5)
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.
Is there any find_in_set function similar to mysql in oracle?
The find_in_set function is good. Unfortunately, it is not in Oracle, but we can apply it in disguise, which can also achieve the same effect.
Select
Decode (teii. item_num, 'gmexin10484', 1, 'hxexin10472', 2, 'hxexin10471', 3, 'gmexin10487', 4, 'gmexin10483 ', 5) sequence,
Teii .*
From t_exam_item_info teii
Where teii. item_num in ('gmexin10484 ', 'hxexin10472', 'hxexin10471', 'gmexin10487', 'gmexin10483 ')
Order by decode (teii. item_num, 'gmexin10484', 1, 'hxexin10472', 2, 'hxexin10471', 3, 'gmexin10487', 4, 'gmexin10483', 5 );
Can the first mysql find_in_set parameter be multiple values?
FIND_IN_SET (str, strlist)
If the str string is in the strlist consisting of N substrings, the return value ranges from 1 to N. A string list is a string consisting of several tokens separated by commas. If the first parameter is a constant string and the second parameter is the type SET column, the FIND_IN_SET () function is optimized and computed in bits. If str is not in strlist or strlist is a null string, the return value is 0. If any parameter is NULL, the return value is NULL. This function cannot run normally when the first parameter contains a comma.
This function cannot run normally when the first parameter contains a comma.