gpt4 book ai didi

mysql - 使用逗号分隔列表在列中查找逗号分隔值

转载 作者:行者123 更新时间:2023-11-29 05:02:53 25 4
gpt4 key购买 nike

<分区>

我有一个 item_id_list 列,其中包含逗号分隔的 id,如下所示:

enter image description here

我可以使用 FIND_IN_SET() 搜索它们,如下所示:

SELECT * FROM task_detail WHERE FIND_IN_SET('21', item_id_list)

但我需要检查该行中是否确实存在多个 id,但添加另一个 id 进行搜索将不会像文档中所述那样工作。

https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_find-in-set

This function does not work properly if the first argument contains a comma (,) character.

SELECT * FROM task_detail WHERE FIND_IN_SET('21, 79', item_id_list)

在不改变我的表结构的情况下,如何解决这个问题?现在通过 id 数循环 FIND_IN_SET() 是解决方案。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com