Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010

    Unanswered: Select distinct from left join


    I have query but i got problem in data which I need to DISTINCT.

    here is my query:

    SELECT p.PCODE, p.min_lot, p.max_lot, kd.LOT_CODE, kd.wip_chemicalweighing, kd.wip_compounding, kd.wip_extrusion, kd.wip_forming, 
    kd.wip_deflashing, kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion, kc.count_wip_forming, 
    kc.count_wip_deflashing, kc.kanban, kc.virtual FROM (SELECT DISTINCT PCODE, min_lot, max_lot FROM plan) AS p
    LEFT JOIN (SELECT LOT_CODE, PCODE, wip_chemicalweighing, wip_compounding, wip_extrusion, wip_forming, 
    wip_deflashing FROM kanban_data ORDER BY PCODE) AS kd ON (p.PCODE = kd.PCODE)
    LEFT JOIN (SELECT DISTINCT PCODE, count_wip_chemical_weighing, count_wip_compounding, count_wip_extrusion, count_wip_forming, 
    count_wip_deflashing, kanban, virtual FROM kanban_checker ORDER BY PCODE) AS kc ON p.PCODE = kc.PCODE;
    I need to distinct data FROM tables plan and kanban_checker.

    Thank you..

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    Quote Originally Posted by newphpcoder View Post
    I need to distinct data FROM tables plan and kanban_checker.
    based on the amount of information you've provided, your solution is dead simple -- use the word DISTINCT right after the word SELECT

    this will ensure that every row produced is distinct

    if that's not what you really want, then you will have to explain more | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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