目前我有这个查询:
SELECT column1,column2 FROM table
column1 需要不同,column2 则不需要。
SELECT DISTINCT column1, NON-DISTINCT column2 FROM table
现在我知道这没有意义,但我需要column1 是不同的,column2 是任何东西。我该怎么做。
最佳答案
select pid, group_concat(distinct bla1) as bla1s
from table
group by pid;
上面将为每个 pid 获取 1 行,您将能够查看是否有额外的 bla1,而无需引入新列或不必随机选择多个 bla1。
关于PHP MYSQL 多个或单个 DISTINCT/UNIQUE 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1410345/