Christan Andersson wrote:
> what I really want is the following..
> let say that the table (id,language,name,description) where id,language is
> the primary key so that 1 id can have several languages
>
> the data in the database looks like this
>
> 1 'en' 'blue circle' 'this is a blue '
> 1 'no' 'bla cirkel' 'dette er ei bla cirkel'
> 2 'en' 'green leaf' 'this is a green leaf from a tree'
> 2 'sv' 'gr�nt l�v' 'detta �r ett gr�nt l�v fr�n ett tr�d'
>
> if the language priority is en,sv,no the "select"would return the following
> 1 'en' 'blue circle' 'this is a blue '
> 2 'en' 'green leaf' 'this is a green leaf from a tree'
>
> if however the language prority was sv,no,en the select should return the
> following
> 1 'no' 'bla cirkel' 'dette er ei bla cirkel'
> 2 'sv' 'gr�nt l�v' 'detta �r ett gr�nt l�v fr�n ett tr�d'
Ah. That's quite different. You can't do this using GROUP BY either, by the
way.
You'd have to compute some value column based on the language and the
preference list such that the first choice language evaluates to 1, the
second choice language evaluates to 2, etc. (See the CASE function under
Control Flow functions).
You'd then need to do one select with group-by to get the "MIN" of this
value for each article number, which will give you the article ID and the
mapped value that's the least, for each article, which you can shove into a
temporary table. You then have to join that against the whole table to get
the rest of the details.
Or something along those lines. Or else, just order by such a map function,
and use software logic to only select the first returned value for each
article number, which may well be faster..
--
Shankar.
---------------------------------------------------------------------
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