coding ++: MySQL function --FIND_IN_SET ()

Syntax: FIND_IN_SET (str, strlist)

Definitions :

1). If the string  str N sub-chains by a string list  strlist, the value returned in the range between 1 to N.

2) a list of strings is a string of some of ',' symbol separate from the chain.

3) If the first parameter is a string constant, and the second is typeSET column, the FIND_IN_SET () function is optimized, the use of bits is calculated.

4) If not strlist str strlist or empty string, the return value is 0.

5) as in any one parameter is NULL, return value is NULL. This will not work when the first argument function contains a comma ( ',').

strlist : a comma a "," link string, for example: "a, b, c, d", similar to the string form of the value of SET type is linked to a comma.

Example: the SELECT the FIND_IN_SET ( 'B', 'A, B, C, D');  // return value 2, i.e. the second value

// query 9824 if the value is present in the Field column community_id 

the SELECT * the FROM `cc_stop_gas_notice` 
the WHERE the FIND_IN_SET ( '9824',` cc_stop_gas_notice`.`community_id`)

 

Guess you like

Origin www.cnblogs.com/mlq2017/p/11792118.html