multiple values in mysql variable

后端 未结 6 2023
渐次进展
渐次进展 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

    Something like this should work. Is it ok to use prepared statements to create temporary tables like this?

    SET @a := "'20100630', '20100701'";
    SET @sql = CONCAT('create temporary table pn1 SELECT * FROM wordbase WHERE verified IN (', @a, ')');
    PREPARE stmt FROM @sql;
    EXECUTE stmt;
    
    select * from pn1;
    

提交回复
热议问题