Hello,
I'd like to find a solution for this: http://drupal.org/node/78973
Suppose I have a table like this:
nid trid lang
2 0 ia
1 1 ia
3 1 en
4 2 ia
5 2 en
6 2 it
7 0 ia
8 4 ia
9 4 en
10 4 it
11 0 ia
The "nid" is the node number, "lang" is the language the node is written in, and "trid" is used to group together the translation equivalents: that is, nodes 4,5,6 describe the same content in three different languages. If "trid" is 0, then the node has not been translated into other languages.
What I'm looking for is a query that filters out records in this table like this ("lang_user" and "lang_default" are two PHP variables which are known at the time the query is written; think of them as "en" and "ia"):
1) if "trid" is 0, then keep the record
2) if lang = lang_user, keep this record and filter out all other records having the same "trid"
3) if lang = lang_default, keep this record and filter out all other records having the same "trid"
4) filter out this record
My question is, can all this be achived within a single SQL statement (I guess no, but I'm not a SQL expert)?
If not, I guess I'll have to code a patch to drupal core, if I want to solve the issue http://drupal.org/node/78973, I am right?