Assuming that there is a one-to-one relationship between the tables on the
FunctionID (meaning there is only one entry in Functions for each
FunctionID), then...

SELECT Names.NameID, Names.Name, Names.FunctionID, Functions.FunctionName
FROM Names LEFT JOIN Functions ON (Names.FunctionID=Functions.FunctionID);

The resulting FunctionName will be NULL if a match is not found.



Roy Nasser <[EMAIL PROTECTED]> 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! :)





Roy Nasser
CTO
Vem Cá Servicos de Internet S/C Ltda.
Av. Paulista 2421 14* Andar
São Paulo SP Brasil
55 11 3347 3456 / 9953 8853 - cel
www.jarbas.com.br
[EMAIL PROTECTED]







---------------------------------------------------------------------
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