我想显示相同的ID数据

时间:2013-09-25 09:13:33

标签: php html mysql

我无法理解我的问题。我有这样的数据库。

   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

现在我想用“003”这样的ID显示进攻。我希望用HTML这样显示它。

 ID             Offense                Remarks
003             No ID              Community Service
003     not in proper uniform      Community Service.

3 个答案:

答案 0 :(得分:1)

SELECT * FROM <table> GROUP BY ID, Offense;

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

答案 1 :(得分:1)

使用DISTINCT

SELECT DISTINCT FROM ....

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

  

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

答案 2 :(得分:1)

SQL Query将是:

SELECT ID, DISTINCT Offense, Remarks FROM youtable WHERE ID = '03'
相关问题