mysql FIND_IN_SET 用法,mysqlfind_in_set

來源:互聯網
上載者:User

mysql FIND_IN_SET 用法,mysqlfind_in_set

mysql 中 FIND_IN_SET  是判斷某個字串是否在帶逗號的字串中

例如 

SELECT  t.group_id,  COUNT(group_id)    tsumFROM (SELECT        group_id      FROM xx      WHERE FIND_IN_SET(openid,'qqqwqnfocFq5IL2sXB2Qu0I,oarwerrr-2KRah_TklJEomljhlKg,oaSiouEgtr5t5utLFU8-evmkn5BwQ3_c')          AND user_uuid = 'xxxxxxxxxxxx') tGROUP BY group_id;
這樣就能找出相匹配的資料

後者是帶逗號的字元


java 中 使用 find_in_set關鍵字查詢mysql,怎傳值?

完全可以在java中使用,只要你傳入的是個字串而且使用逗號分隔就可以了
 
mysql find_in_set 第一個參數可不可以是多個值

FIND_IN_SET(str,strlist)
假如字串str 在由N 子鏈組成的字串列表strlist 中, 則傳回值的範圍在 1 到 N 之間 。一個字串列表就是一個由一些被‘,’符號分開的自鏈組成的字串。如果第一個參數是一個常數字串,而第二個是type SET列,則 FIND_IN_SET() 函數被最佳化,使用位元計算。如果str不在strlist 或strlist 為空白字串,則傳回值為 0 。如任意一個參數為NULL,則傳回值為 NULL。 這個函數在第一個參數包含一個逗號(‘,’)時將無法正常運行。

這個函數在第一個參數包含一個逗號(‘,’)時將無法正常運行。
 

相關文章

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.