IN and find in mysql

Source: Internet
Author: User
FIND_IN_SET (str, strlist) if the str string is in the strlist consisting of N sub-chains, the return range is between 1 and 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 a typeSET column, then

FIND_IN_SET (str, strlist) if the str string is in the strlist consisting of N sub-chains, the return range is between 1 and 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, then

  • FIND_IN_SET (Str,Strlist)
Assume that the string StrIn NString list composed of substrings Strlist, The returned value range is 1 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 bit computing is used. If StrNo StrlistOr StrlistIf it 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.

Mysql>SELECT FIND_IN_SET ('B', 'a, B, c, D ');

-> 2

Extended usage, sorted by FIND_IN_set

Eg:

$ Ids = '9 ';

$ SQL = "... WHERE goods_id IN ('{$ ids}') ORDER BY FIND_IN_SET (goods_id, '{$ ids }')";

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.