#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    39
    Rep Power
    11

    Question about Duplicate Records


    Hey -
    Can someone help me?

    Basically i have a table with 37,000 records. Each record has the person reponsible name. Each name is used more than once. Whenever I preform the following SQL Query:
    SELECT YKPC_EXT_Orders.ACCOUNTANT, YKPC_EXT_Orders.FULL_NAME
    FROM YKPC_EXT_Orders;

    It displays a table with their full name and userid like its supposed to but it displays duplicates of each name. Say that persons name was in 30 records, it would display their name 30 times. Is there any way i could put a constraint on my SQL statement so when i run the query, it wont show each name more than once??

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,784
    Rep Power
    348
    SELECT DISTINCT ykpc_ext_orders.accountant,
    ykpc_ext_orders.full_name
    FROM ykpc_ext_orders;

    But this is just fighting the symptoms of a bad database design.

    Put your accountants into a separate table with user id and full name, and then store the user_id in the ykpc_ext_orders table. This is called "normalizing"

IMN logo majestic logo threadwatch logo seochat tools logo