簡體   English   中英

SQL select 基於列引用不同 - 查詢 Mysql

[英]SQL select distinct based on a columns reference - Query Mysql

我需要區分一列,但它基於另一列。

這是一個例子

colA colB
---------
a   1 
a   1 
a   2 
a   3

b   1
b   2 
b   2 
b   4 

c   1
c   1 
c   2
c   2 

預期結果

a   1 
a   2 
a   3

b   1
b   2 
b   4 

c   1
c   2 

任何人有任何想法請查詢 mysql? .

謝謝

只需寫Select Distinct Column1, Column2 from Table

Distinct 將為您提供唯一的元組,因此源集中您指定的列的唯一組合。

嘗試“不同”。 如果您只想區分 2 列,請嘗試“ GROUP BY ”。 這是演示: https://www.w3schools.com/sql/sql_groupby.asp

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM