default result

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
piuga
Forum Newbie
Posts: 9
Joined: Fri May 10, 2002 11:24 am
Location: Relative to what?

default result

Post by piuga »

I'm working on a localisation-tool and would really like if it was possible to get a result like this:

table strings:

Code: Select all

id    locale   identifier  string
-----|--------|-----------|------
 1     2         1          Hello
 2     2         2          Bye
 3     3         1          Hej
and then making a query to get all the strings where the locale is 3 and get "Hej", "Bye" as the result (assuming 2 is the default locale).

If this is not possible maybe I should make sure that the default locale really is a default locale and always dummy in it's strings for the other locales (in my opinion a much dirtier sollution)
User avatar
piuga
Forum Newbie
Posts: 9
Joined: Fri May 10, 2002 11:24 am
Location: Relative to what?

Impatience is the master of sollution

Post by piuga »

Ok, looks like I solved it, thanks for not responding in like 30 minutes or so!

Code: Select all

select s.* from 
pl_strings s, pl_identifiers i, pl_contexts c 
where 
  (c.context="general")
  and
  (i.context_id=c.id)
  and
  (s.identifier_id=i.id)
  and 
  (
    (s.locale_id = 29)
    or
    (s.locale_id = 31)
  )
  group by s.identifier_id
;
It would be nice though if some guru could verify this...

cheers
Post Reply