List:General Discussion« Previous MessageNext Message »
From:Gerald L. Clark Date:July 18 2006 8:15pm
Subject:Re: Distinct problem
View as plain text  
Tanner Postert wrote:
> I actually solved my own problem...
> 
> SELECT t1.item_id, t1.dt, t1.text ,t3.*
> FROM table AS t1, table3 as t3
> LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AND t1.dt < t2.dt
> WHERE t2.item_id IS NULL;
> 
> becomes
> 
> SELECT t1.item_id, t1.dt, t1.text
> FROM (table AS t1, table3 as t3)
> LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AND t1.dt < t2.dt
> WHERE t2.item_id IS NULL;
> 
> amazing what a little set of parenthesis will do. thanks anyways.
> 
> 
> 
>
t3 is not joined at all.

Re-write this using inner joins to see your problem.

SELECT t1.item_id, t1.dt, t1.text
FROM table AS t1 INNER JOIN table3 AS t3 ON ???????
LEFT JOIN table AS t2 ON t1.item_id = t2.item_id AND t1.dt < t2.dt
WHERE t2.item_id IS NULL;



-- 
Gerald L. Clark
Supplier Systems Corporation
Thread
Distinct problemTanner Postert28 Jun
  • Re: Distinct problemDan Buettner28 Jun
  • Re: Distinct problemPeter Brawley29 Jun
    • Re: Distinct problemTanner Postert18 Jul
      • Re: Distinct problemTanner Postert18 Jul
        • Re: Distinct problemGerald L. Clark18 Jul