In the last episode (Oct 17), Stas Bekman said:
> When I execute
> SELECT ... WHERE lang='en' OR lang='fr';
> I get *all* the matching records.
> What I want is to match only records where lang='en' and if it's not
> there than to match the records where lang='fr'.
So you've got a table like:
docID | lang | transID | body
1 | en | 1 | "Text in english"
1 | fr | 2 | "Text en francais"
2 | fr | 3 | "Text en francais"
3 | en | 4 | "Text in english"
And you want a french-speaking user to get translation #2 in preference to
translation #1 when they request document #1?
You'll probably have to do a 2-stage query. Select the docID, transID
and lang for all the documents you're interested in, then figure out
which records from the database you actually want and pull them by
transID another query. Create a 3-field index on docID, lang, and
transID for faster lookups.
With subqueries you could probably handle the whole thing in one query,
but MySQL doesn't have them.