multiple values in mysql variable

后端 未结 6 2020
渐次进展
渐次进展 2021-02-05 13:49

The following works as expected when there is a single value stored in a variable.

SET @a := \"20100630\";
SELECT * FROM wordbase WHERE verified = @a;
         


        
6条回答
  •  伪装坚强ぢ
    2021-02-05 13:59

    FIND_IN_SET(column to find in , string csv) is a very handy method in case you have the string list of CSV:

    SET @a := "'20100630', '20100701' ";
    SELECT * FROM wordbase WHERE FIND_IN_SET(verified, @a);
    

    if your variable is also coming from query then use this to set @a

    SET @a := (SELECT GROUP_CONCAT(`id`) FROM `table`);
    

提交回复
热议问题