<bdo id='3yzwZ'></bdo><ul id='3yzwZ'></ul>

  1. <tfoot id='3yzwZ'></tfoot>

    <small id='3yzwZ'></small><noframes id='3yzwZ'>

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

      在 MySQL 中返回枚举值的最佳方法是什么?

      What is the best way to return enum values in MySQL?(在 MySQL 中返回枚举值的最佳方法是什么?)

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

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

          <legend id='uVRp2'><style id='uVRp2'><dir id='uVRp2'><q id='uVRp2'></q></dir></style></legend>

          <tfoot id='uVRp2'></tfoot>

            <bdo id='uVRp2'></bdo><ul id='uVRp2'></ul>
              • 本文介绍了在 MySQL 中返回枚举值的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要选择一列的枚举值.通过搜索,我发现了两种方法:

                I need to select the enum values of a column. From searching I've found two ways:

                SELECT column_type FROM information_schema.columns 
                WHERE table_name = 'MyTable' AND column_name = 'MyColumn';
                

                另一个:

                SHOW COLUMNS FROM `mytable` WHERE field = 'type';
                

                虽然第一个查询会给我这个信息:

                Although the first query will give me this info:

                enum('value1','value2','value3')
                

                第二个查询为我提供了相同的信息,并且还提供了额外的列.我宁愿只获取那些没有 enum() 和逗号的值,是否可能,或者我是否需要解析这些值?并不是说检查是否有更简单的方法很难.

                The second query gives me the same and with additional columns as well. I would prefer to just get those values without the enum() and commas, is it possible, or do I need to parse the values out? Not that it's hard just checking if there is an easier way.

                假设没有更简单的方法,上面两个查询哪个更好用?我注意到第二个查询在我运行时没有显示查询时间,我几乎认为它根本不需要任何时间.但是如果我打开分析器,我可以看到它确实需要时间,但它似乎快了一点.那么第二个查询会更有效吗?

                Assuming there is no easier way, which of the two queries above is better to use? I noticed that the second query doesn't show the query time when I ran it, I almost thought it didn't require any time at all. But if I turn on the profiler I can see that it does take time, but it seem a bit faster. So would the second query be more efficient?

                推荐答案

                我猜你不能选择这些值,我最终用这个解析了这些值:

                I guess you can't select those values out, I ended up parsing the values out with this:

                $result = str_replace(array("enum('", "')", "''"), array('', '', "'"), $result);
                $arr = explode("','", $result);
                return $arr;
                

                这篇关于在 MySQL 中返回枚举值的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
                MySQL cumulative sum grouped by date(按日期分组的 MySQL 累计总和)
                1. <small id='YVcZm'></small><noframes id='YVcZm'>

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