隐藏重复的列值

时间:2013-05-14 19:05:24

标签: php

我有一个mysql数据库,其中包括两个名为个人和家庭的表。个人表的字段包括:

-ind_id
-first_name
-middle_name
-last_name
-household_id

住户表的字段包括:

-household_id
-head_first_name
-head_middle_name
-head_last_name
-address
-city
-province_state
-country
-postal_code
-phone

两个表中的household_id字段之间存在foriegn密钥关系。这两个表的目的是将个人分组到不同的家庭中,并能够生成一份报告,列出从数据库中选择个人并按家庭分组。那不是问题。使用SQL和PHP,我可以生成如下所示的列表:

-Household Head       Address                                 Phone              Occupants
-Jones, Robert John 1234 Deadend St., Anytown, USA 98004    (555) 420-5186     Jones, Ann Leslie
-Jones, Robert John 1234 Deadend St., Anytown, USA 98004    (555) 420-5186     Jones, Percy James
-Jones, Robert John 1234 Deadend St., Anytown, USA 98004    (555) 420-5186     Jones, Robert John
-Smith, John George 3567 Hollywood Blvd., Mytown, USA 97467 (308) 562-8913     Smith, Amanda Jane
-Smith, John George 3567 Hollywood Blvd., Mytown, USA 97467 (308) 562-8913     Smith, John George   
-Smith, John George 3567 Hollywood Blvd., Mytown, USA 97467 (308) 562-8913     Smith, June Anne
-Smith, John George 3567 Hollywood Blvd., Mytown, USA 97467 (308) 562-8913     Smith, Winnifred

我想生成一个隐藏重复值的列表,以便相同的输出显示如下:

-Household Head         Address                             Phone               Occupants
-Jones, Robert John 1234 Deadend St., Anytown, USA 98004    (555) 420-5186      Jones, Ann Leslie
-                                                                               Jones, Percy James
-                                                                               Jones, Robert John
-Smith, John George 3567 Hollywood Blvd., Mytown, USA 97467 (308) 562-8913      Smith, Amanda Jane  
-                                                                               Smith, John George 
-                                                                               Smith, June Anne
-                                                                               Smith, Winnifred

我仍然需要所有行都在记录集中,我只是不希望它们显示在PHP页面上。我想要做的就是阻止重复值显示在输出中。有什么建议吗?

0 个答案:

没有答案