www.webdeveloper.com
Results 1 to 3 of 3

Thread: Select distinct from left join

  1. #1
    Join Date
    Oct 2011
    Posts
    349

    Select distinct from left join

    Hi..

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

    here is my query:

    Code:
    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
    Feb 2012
    Location
    youTUBE
    Posts
    234
    Are you getting NULLS?

    select distinct p.CODE,kd.wip_compounding
    from
    (joins as p and kd)
    where p.CODE is not null

  3. #3
    Join Date
    Sep 2011
    Posts
    3
    hi newphpcoder,
    you have made the code a complex one.. may be you can split it up and see what it results to.

    web development services

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles