> select distinct > t1.textkey, > if(t2.textid,t2.languageid,t3.languageid) as languageid, > if(t2.textid,t2.textid,t3.textid) as textid, > if(t2.textid,t2.textvalue,t3.textvalue) as textvalue > from texts t1 > left join texts t2 on > t2.textkey=t1.textkey and > t2.languageid='da' > left join texts t3 on > t3.textkey=t1.textkey and > t3.languageid='en'; > > I don't know if you always have at least one of 'da' or 'en' for every > possible textkey, and what behaviour you would like if you don't. If you > always have at least one of them, the statement could be simplified.
Do you mean something like this then: select distinct t1.textkey, if(t2.textid,t2.languageid,t1.languageid) as languageid, if(t2.textid,t2.textid,t1.textid) as textid, if(t2.textid,t2.textvalue,t1.textvalue) as textvalue from texts t1 left join texts t2 on t2.textkey=t1.textkey and t2.languageid='da' WHERE t1.languageid='da' or t1.languageid='en' I would emagine that only one 'left join' takes less processing power? One thing that I have been wondering about, is if such a query like this, is too power-hungry if it has to be run every time you do anything on a homepage. One possibility is to cache the result in a session. Merry christmas from Stig in Denmark! --------------------------------------------------------------------- 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