duanlie3187 2013-05-14 19:05
浏览 18

隐藏重复的列值

I have a mysql database that includes two tables called individuals and households. The fields for the individuals table include:

-ind_id
-first_name
-middle_name
-last_name
-household_id

The fields for the households table include:

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

There is foriegn key relationship between the household_id fields in the two tables. The intent of the two tables is to group individuals into various households and to be able to produce a report listing selecting individuals from the database and group them by household. That isn't a problem. Using SQL and PHP, I have no problem producing a list that looks like this:

-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

I want to produce a list that hides the repeated values, so that the same output would display like this:

-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

I still need all of the rows to be in the record set, I just don't want them to display on PHP page. All I want to do is prevent the duplicate values from displaying in the output. Any suggestions?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度