2013-09-25 62 views
0

我无法得到我的问题的逻辑。我有这样的数据库。我想显示相同的ID数据

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. 

回答

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

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

+0

我怎么会显示这个在HTML? – Levy

+0

@Levy HTML不会处理您将需要PHP的代码。 – Prix

+0

对于该用途,应该使用'php'获取这些数据,然后将其显示到'html'。 –

1

SQL查询将是:

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