I think I got it working...
thanks!

I had a few pretty complex queries, so it took a little while to understand,
and then convert all of them! :)

> -----Original Message-----
> From: Eric Fitzgerald [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 28, 2001 8:56 PM
> To: Roy Nasser; 'nigel wood'; [EMAIL PROTECTED]
> Subject: Re: Is it possible to use an "optional field"?
> 
> 
> Your query converted to using left joins:
> SELECT DISTINCT Questions.QuestionID, Questions.Question,
> Experts.ExpertFullName, Category.CategoryName, Questions.Shows,
> Questions.Views
> FROM Questions
>     LEFT JOIN Experts ON (Questions.ExpertID = Experts.ExpertID)
>     LEFT JOIN Category ON (Questions.CategoryID = Category.CategoryID)
> WHERE Questions.OnHold = 2 GROUP BY Questions.QuestionID
> 
> That will grab each record in the Questions table, and return data in
> Experts and Categories *IF* it exists, otherwise nulls.
> 
> ----- Original Message -----
> From: "Roy Nasser" <[EMAIL PROTECTED]>
> To: "'nigel wood'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, March 28, 2001 3:18 PM
> Subject: RE: Is it possible to use an "optional field"?
> 
> 
> > I took a look at the manual, but I am a bit unsure of how 
> this would be
> done
> > in a multi-table wuery, such as the one below... if anyone can help,
> greatly
> > appreciated! :)
> >
> > SELECT DISTINCT Questions.QuestionID, Questions.Question,
> > Experts.ExpertFullName, Category.CategoryName, Questions.Shows,
> > Questions.Views FROM Questions, Experts, Category WHERE
> > (Questions.ClientID='15') AND (Questions.ExpertID = 
> Experts.ExpertID) AND
> > (Questions.CategoryID = Category.CategoryID) AND 
> Questions.OnHold=2 GROUP
> BY
> > Questions.QuestionID;
> >
> > Thank you for all help!
> >
> > As usual, please Reply All! :)
> >
> >
> > > -----Original Message-----
> > > From: nigel wood [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, March 28, 2001 8:16 PM
> > > To: Roy Nasser
> > > Subject: Re: Is it possible to use an "optional field"?
> > >
> > >
> > > On Wed, 28 Mar 2001, you wrote:
> > > > Hi,
> > > >
> > > > I have two joined tables (three actually, but for an
> > > example, 2 is OK)...
> > > >
> > > > example:
> > > >
> > > > Names / Function
> > > >
> > > > Then in names I have NameID, Name, and FunctionID, and in
> > > Function table, I
> > > > havce FunctionID, and FunctionName...
> > > >
> > > > therefore, I need to find the Function Name of a Person,
> > > through their
> > > > name... - simple engouh until this point...
> > > >
> > > > SELECT Names.NameID, Names.Name, Names.FunctionID,
> > > Functions.FunctionName
> > > > WHERE (Functions.FunctionID = Names.FunctionID)...
> > > >
> > > > However, in some cases, Names.FunctionID might be empty, or
> > > not match
> > > > anything in Functions table, and in this case I want the
> > > > Functions.FunctionName to show up as null, or empty...
> > > >
> > > > I have been told that in MS Sql, the query would be
> > > something like the
> > > > above, with the where like this: WHERE
> > > > (Names.FunctionID=*Functions.FunctionID)
> > > >
> > > > This did not work in MySQL 3.23.30... Can you help?
> > > >
> > > > Thanks!
> > > >
> > > > PS: Please reply directly to me... (Reply All)... Thanks! :)
> > >
> > > Look up LEFT JOIN in the manual & get a copy of PaulBois's
> > > 'MySQL' book
> > >
> > > Nigel
> > >
> >
> > 
> ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail 
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: 
> http://lists.mysql.com/php/unsubscribe.php
> >
> >
> >
> 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to