我想显示相同的 ID 数据


I want to show same ID data

我无法理解我问题的逻辑。我有一个这样的数据库。

   ID      |     Offense     |    Remarks  
   003          No Id              Community service
   020          No Id              Community service
   012          No Id              Community service
   003          No Id              Community service
   003   Not in proper uniform     Community service

现在我想显示具有相同 ID 的进攻,例如"003"。我想像这样用HTML显示它。

 ID             Offense                Remarks
003             No ID              Community Service
003     not in proper uniform      Community Service.
SELECT * FROM <table> GROUP BY ID, Offense;

您应该参考 - http://dev.mysql.com/doc/refman/5.0/en/select.html

使用 DISTINCT

SELECT DISTINCT FROM ....

http://dev.mysql.com/doc/refman/5.0/en/select.html

DISTINCT 指定从结果集中删除重复的行。

SQL 查询将是:

SELECT ID, DISTINCT Offense, Remarks FROM youtable WHERE ID = '03'