• <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 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to delete duplicate records in mysql database?(如何删除mysql数据库中的重复记录?)
                  Python Pandas write to sql with NaN values(Python Pandas 使用 NaN 值写入 sql)
                  MySQL Insert amp; Joins(MySQL 插入 amp;加入)
                  MySQL concat() to create column names to be used in a query?(MySQL concat() 创建要在查询中使用的列名?)
                  NodeJS responded MySQL timezone is different when I fetch directly from MySQL(当我直接从 MySQL 获取时,NodeJS 响应 MySQL 时区不同)
                  WHERE datetime older than some time (eg. 15 minutes)(WHERE 日期时间早于某个时间(例如 15 分钟))

                    <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>