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

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

          <bdo id='Z3V6O'></bdo><ul id='Z3V6O'></ul>

        MYSQL 选择两列中的 DISTINCT 值

        MYSQL select DISTINCT values in two columns(MYSQL 选择两列中的 DISTINCT 值)

      1. <tfoot id='cqxaS'></tfoot>

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

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

              <bdo id='cqxaS'></bdo><ul id='cqxaS'></ul>
                <tbody id='cqxaS'></tbody>
                  本文介绍了MYSQL 选择两列中的 DISTINCT 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在数据库中选择不同的值.让我通过一个简单的例子来告诉你.

                  I want to select distinct values in a database. Let me run you through a quick example.

                  表格:

                  foo bar
                  --- ---
                  a   c
                  c   f
                  d   a
                  c   a
                  f   c
                  a   c
                  d   a
                  a   c
                  c   a
                  f   c
                  

                  好吧,假设我的 SQL 是 SELECT DISTINCT foo, bar from table.这些是我的结果:

                  Right, let's say my SQL is SELECT DISTINCT foo, bar from table. These are my results:

                  foo bar
                  --- ---
                  a   c
                  c   f
                  d   a
                  c   a
                  f   c
                  

                  然而,问题是存在 a c/c a 的重复,只是它们的顺序不同.我不想选择这些,我想要两列的不同值,请帮忙!

                  However the problem is is that there are repetitions of a c / c a just that they are in a different order. I don't want to select these, I want distinct values from both columns, please help!

                  推荐答案

                  非常非常邪恶 &邪恶:

                  very very wicked & evil:

                  select distinct
                      least(foo, bar) as value1
                    , greatest(foo, bar) as value2
                  from table
                  

                  这篇关于MYSQL 选择两列中的 DISTINCT 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  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 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)

                    <tfoot id='UbX0D'></tfoot>
                      <tbody id='UbX0D'></tbody>
                    • <small id='UbX0D'></small><noframes id='UbX0D'>

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