<i id='SgKvm'><tr id='SgKvm'><dt id='SgKvm'><q id='SgKvm'><span id='SgKvm'><b id='SgKvm'><form id='SgKvm'><ins id='SgKvm'></ins><ul id='SgKvm'></ul><sub id='SgKvm'></sub></form><legend id='SgKvm'></legend><bdo id='SgKvm'><pre id='SgKvm'><center id='SgKvm'></center></pre></bdo></b><th id='SgKvm'></th></span></q></dt></tr></i><div id='SgKvm'><tfoot id='SgKvm'></tfoot><dl id='SgKvm'><fieldset id='SgKvm'></fieldset></dl></div>

    <small id='SgKvm'></small><noframes id='SgKvm'>

    <tfoot id='SgKvm'></tfoot>
    • <bdo id='SgKvm'></bdo><ul id='SgKvm'></ul>
  1. <legend id='SgKvm'><style id='SgKvm'><dir id='SgKvm'><q id='SgKvm'></q></dir></style></legend>

      MySQL 在逗号列表中搜索

      时间:2023-06-03
        <tbody id='w38kD'></tbody>
      • <bdo id='w38kD'></bdo><ul id='w38kD'></ul>
        • <legend id='w38kD'><style id='w38kD'><dir id='w38kD'><q id='w38kD'></q></dir></style></legend>

              <small id='w38kD'></small><noframes id='w38kD'>

              <tfoot id='w38kD'></tfoot>

                <i id='w38kD'><tr id='w38kD'><dt id='w38kD'><q id='w38kD'><span id='w38kD'><b id='w38kD'><form id='w38kD'><ins id='w38kD'></ins><ul id='w38kD'></ul><sub id='w38kD'></sub></form><legend id='w38kD'></legend><bdo id='w38kD'><pre id='w38kD'><center id='w38kD'></center></pre></bdo></b><th id='w38kD'></th></span></q></dt></tr></i><div id='w38kD'><tfoot id='w38kD'></tfoot><dl id='w38kD'><fieldset id='w38kD'></fieldset></dl></div>
                本文介绍了MySQL 在逗号列表中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个 MySQL 字段,其中引用了另一个表,其中 id 保存为逗号分隔列表,例如:

                I have a MySQL field with a reference to another table where ids are saved as comma seperated list, eg:

                12,13,14,16
                

                代表另一个表中的值.我知道这是非常糟糕和错误的,但这是来自上面的,我对此无能为力.现在的问题是我想用这样的查询在该字段中进行搜索:

                which stand for values in another table. I know this is very bad and wrong, but this comes from above and I cant do anything about that. The problem now is that i want to search in that field with a query like this:

                SELECT ... WHERE field LIKE '%1%'
                

                现在的问题显然是几乎所有条目都可以在这个示例查询中找到,因为最常见的 ID 位于 10-20 范围内.我的想法是搜索 %,1,% ,但这不适用于该字段中的第一个和最后一个 id.是否有内部替换之类的东西,或者我如何以最好的方式解决这个问题?

                The Problem now is obviously that almost all entries can be found with this example Query, because the most common IDs are in Range 10-20. My Idea is to search for %,1,% instead, but this does not work for the first and last id in the field. Ist there something like an internal replace or how do i fix this the best way?

                推荐答案

                您需要 FIND_IN_SET 函数:

                You need the FIND_IN_SET function:

                SELECT ... WHERE FIND_IN_SET('1', field)
                

                这篇关于MySQL 在逗号列表中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Visual Studio 2012 上的 mySQL 数据源 下一篇:如何在两个 Django 应用程序之间移动模型(Django 1.7)

                相关文章

                <legend id='7HP2z'><style id='7HP2z'><dir id='7HP2z'><q id='7HP2z'></q></dir></style></legend>
                <tfoot id='7HP2z'></tfoot>
                <i id='7HP2z'><tr id='7HP2z'><dt id='7HP2z'><q id='7HP2z'><span id='7HP2z'><b id='7HP2z'><form id='7HP2z'><ins id='7HP2z'></ins><ul id='7HP2z'></ul><sub id='7HP2z'></sub></form><legend id='7HP2z'></legend><bdo id='7HP2z'><pre id='7HP2z'><center id='7HP2z'></center></pre></bdo></b><th id='7HP2z'></th></span></q></dt></tr></i><div id='7HP2z'><tfoot id='7HP2z'></tfoot><dl id='7HP2z'><fieldset id='7HP2z'></fieldset></dl></div>

                  • <bdo id='7HP2z'></bdo><ul id='7HP2z'></ul>
                1. <small id='7HP2z'></small><noframes id='7HP2z'>