List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 17 1999 3:07pm
Subject:Re: about "left join" help me !!!!!
View as plain text  
On Thu, 1999-09-16 16:36:23 +0800, miweichong wrote:

> I have three tables on my database: content,category,check 
> I want to select some records:
> first:
>       I must find something that content.category=category.id in
>       category.name="some string" and content.level>1;
> second:
>       If I had found 9 records from first step,I must find something
>       which check.contentid=content.id in check.action="some string"
>       from the 9 records.
> 
> So I write SQL statement:
>   select content.title from content left join category on
>   content.category=category.id left join check on
>   content.id=check.contentid where category.name="newsclass" and
>   check.action="OK" and content.level>1;

Hmm, is there some reason to use LEFT JOINs instead of normal joins?

From your description, I'd write:
  SELECT content.title
  FROM   content, category, check
  WHERE  content.category=category.id
     AND content.id=check.contentid
     AND content.level>1
     AND category.name="newsclass"
     AND check.action="OK";

Does this work?

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
about "left join" help me !!!!!joe16 Sep
  • Re: about "left join" help me !!!!!Martin Ramsch17 Sep