sql duplicate problem when populating drop list

Results 1 to 2 of 2

Thread: sql duplicate problem when populating drop list

  1. #1
    Join Date
    Dec 1969

    Default sql duplicate problem when populating drop list

    Theres two tables<BR><BR>Store_Dept and Store_items_adddepts<BR><BR>The store_dept has a list of items that belong in a certain department determined by department_ID. but sometimes the items can be located in more than one department so i store the additional departments in the second table. the second table has a store_ID, Item_ID and department_ID...and i&#039;m joining the two based on the store_ID. Whats happening now is that when i populate a list box...certain items appear more than once (the database only has one entry). ...also in store_Dept...for example theres are items that have the same department_name and are kept distinct by the store_id. My problem is that i don&#039;t want duplicates on the list...thanks a million!<BR><BR>Store_dept has many tables...department_ID, store_id, ref_id, department_name are the important ones involved<BR><BR><BR>CODE:<BR><BR> &#060;% sql_select = "SELECT DISTINCT Store_Dept.Department_ID, Store_Dept.Department_Name,Store_Items_AddDepts.re f_id FROM Store_Dept left join Store_Items_AddDepts on Store_Items_AddDepts.department_id = store_dept.department_id WHERE belong_to = belong_to AND store_dept.store_id = " & store_id & " ORDER BY Department_Name" %&#062;<BR><BR>SELECT DISTINCTROW returns a &#039;,&#039; syntax error.

  2. #2
    Join Date
    Dec 1969

    Default So don't ask for them...

    SELECT DISTINCT means that *ALL* the fields you ask for must be 100% identical or they aren&#039;t DISTINCT.<BR><BR>Since the Store_Items_AddDepts.ref_id isn&#039;t the same for each of the records, the records *ARE* distinct and can&#039;t be combined.<BR><BR>It&#039;s just giving you what you asked for.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts