MySQL Forums
Forum List  »  Newbie

Re: What's wrong with this? (Left Join)
Posted by: Chris Stubben
Date: March 25, 2005 01:54PM

Hi,

If you are trying to 'flatten' out a table, maybe try a different query using crosstab techniques, typically Count(CASE) with a GROUP BY statement. I like IF() better than CASE but its non-standard and instead of counting occurences, use a max() to just report the value and not change or count it. I'm assumming there is only one value for each name and upload combination (if not, there are some other solutions).

select upload,
max( if (name='Address', value, NULL)) as Adress,
max( if (name='City', value, NULL)) as City,
max( if (name='State', value, NULL)) as State,
....

FROM ezu_uploadinfos
GROUP by 1;


I'm not sure what you mean by checking WHERE the email address equals the email address in this table? if its where two identical uploads have the same value for both 'Address' name and 'Email Address' name, then you should only need one self-join to find these cases...


Chris

Options: ReplyQuote


Subject
Written By
Posted
Re: What's wrong with this? (Left Join)
March 25, 2005 01:54PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.