SQL Select 所有 Concat 不同的地方

SQL Select All Where the Concat is Distinct

我希望创建一个 select 语句,当其中两行的串联不同时,我 select 所有列和行。下面是我的 SQL 声明。但是,我不确定如何正确创建此语句,如何编写此语句?

$query = "SELECT * FROM APPROVED 
  WHERE DISTINCT CONCAT(P_NUMBER,'-',A_NUMBER) AS CNUMBER 
  AND (STATUS = 'ACTIVE' OR STATUS = 'CLOSED' OR STATUS = 'CLOSING' OR STATUS = 'PENDING')"; 

DISTINCT 用于列选择。有几种方法可以做到这一点:

SELECT DISTINCT CONCAT(P_NUMBER,'-',A_NUMBER) AS CNUMBER FROM APPROVED WHERE 
AND (STATUS = 'ACTIVE' OR STATUS = 'CLOSED' OR STATUS = 'CLOSING' OR STATUS =     'PENDING')

应该和

做几乎一样的事情
SELECT * FROM APPROVED WHERE 
AND (STATUS = 'ACTIVE' OR STATUS = 'CLOSED' OR STATUS = 'CLOSING' OR STATUS =     'PENDING')
GROUP BY CONCAT(P_NUMBER,'-',A_NUMBER)

第二个不在结果中包含串联,而第一个仅包含串联。您需要将所有列指定为 return.