![]() ![]() SELECT FIND_IN_SET( 'a', NULL) Code language: SQL (Structured Query Language) ( sql ) The following statement also returns NULL because the second argument is NULL. SELECT FIND_IN_SET( NULL, 'x,y,z') Code language: SQL (Structured Query Language) ( sql ) The following statement returns NULL because the first argument is NULL. SELECT FIND_IN_SET( 'a', '') Code language: SQL (Structured Query Language) ( sql ) The following statement also returns 0 because the second argument is empty. SELECT FIND_IN_SET( 'a', 'x,y,z') Code language: SQL (Structured Query Language) ( sql ) The following statement returns 0 because a is not in the 'x,y,z' list. SELECT FIND_IN_SET( 'y', 'x,y,z') - 2 Code language: SQL (Structured Query Language) ( sql ) The following statement returns 2 because y has the second position in 'x,y,z' string. A) MySQL FIND_IN_SET() function simple examples Let’s take some examples to understand how the MySQL FIND_IN_SET works. In addition, MySQL will use bit arithmetic optimization if the needle is a constant string and the haystack is a column of type SET. Note that the function will not work properly if the needle contains a comma (,).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |