You are here: SQL question - linking and gor « PHP SQL « IT news, forums, messages
SQL question - linking and gor

Posted by cluthz on 05/14/07 22:51

Hi there,

I have a table of accounts and emailaddresses, as an account can have more
then one email address.

The email address table has an indicator (email_primaryemail) as to which
email address for a particular account is the primary email address (yes /
no field).

If I want to get to perform a search ONLY on accounts that have no email
address in a single SQL statement (that will also have other search criteria
in it constructed from PHP code depending upon what user entered on a search
web form) would the following method work:

Select * from accounts
left join emailaddresses on (account_key = email_foriegnkey)
where (my other dynamically built search criteria on account) AND
email_primaryemail IS NULL
group by account_key

My doubt comes from the fact when you perform a left join like about and
then have a "group by", for the other fields not grouped on, how do you know
from which of the available results available Mysql compares on.

It's quite a hard question to ask actually and hopefully I have made it
clear. Reading that last paragraph back, probably not, but hopefully someone
will know what I'm getting at.

Thanks in advance if anyone can guide me.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация