簡體   English   中英

PHP和MYSQL - 如何檢查兩行或更多行是否具有相同的字段值

[英]PHP & MYSQL - How To Check If Two Or More Rows Have The Same Field Value

所以這就是我今天無法解決的問題。

我想從數據庫中獲取一些細節。 我不知道如何解釋這一點。 但是這里。

數據庫示例:

標題| 描述| 標識符

1 | 說明| ABC
2 | 說明| ABC
3 | 說明| 高清

我想選擇標識符為“abc”的第一行,然后我想跳過具有相同字段“abc”的下一行。

我正在嘗試在PHP中的SELECT mysql_query中使用它

要獲得完整的行,您可以執行此操作

select * from your_table
where title in 
(
  select min(title)
  from your_table
  group by identifier
)

這個?

SELECT DISTINCT(identifier), title, description FROM tablename

在這種情況下,它也會以'def'返回行。

似乎整數字段稱為“標題”。 這應該抓住最低標題#但是按照您的要求刪除重復項。

select min(title) as firstTitle, description, identifier
  from table_name
  where identifier in (select distinct identifier from table_name)
  group by description, identifier.
select min(TITLE) as TITLE, DESCRIPTION , IDENTIFIER 
From your_table
Group by DESCRIPTION , IDENTIFIER 
select id, description, identifier 
from table group by identifier order by id asc;

暫無
暫無

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

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