【问题标题】:Truncated incorrect DOUBLE value mysql stored procedure截断不正确的 DOUBLE 值 mysql 存储过程
【发布时间】:2018-04-04 12:53:39
【问题描述】:

我正在将数据发送到存储过程并收到截断错误。

 list_of_ids varchar(100)
 select * from table where id in (list_of_ids);
 id's are 1,2,3

如果我发送一个 id 就可以了。 id 列表不起作用。如何发送 id 列表。有没有list=true?

【问题讨论】:

    标签: mysql python-3.x stored-procedures flask


    【解决方案1】:

    您正在尝试将 id 与字符串进行比较:

    select * from table where id in ('1,2,3');
    

    相反,您可以使用 find_in_set 函数。

    select * from table where find_in_set(id, list_of_ids);
    

    【讨论】:

    • 酷。我有点忘记了这一点。 find_in_set 方法是否比插入表然后执行选择更快?
    • 最有可能插入表并进行连接作为查询会更快(find_in_set 可能不使用索引),但除非您有大量数据,否则 find_in_set 是一个不错的选择。
    • 好的,谢谢。我正在查看大量数据。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-07
    相关资源
    最近更新 更多