When you do a search with the ob_vocab installed, you will have this SQL WARNING:
user warning: Unknown column 'v.vid' in 'on clause' query: SELECT t.tid FROM vocabulary v, term_data t LEFT JOIN og_vocab ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != 0) AND t.vid=v.vid in /home/mainapa/workspace/water-drupal/includes/database.mysql.inc on line 172.
The query:
$sql = "SELECT t.tid FROM {vocabulary} v, {term_data} t LEFT JOIN {og_vocab} ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != %d) AND t.vid=v.vid";
I think that is only MYSQL 5 bug, because it give more precedence to JOIN statement.
So the fix is simple:
$sql = "SELECT t.tid FROM ({vocabulary} v, {term_data} t) LEFT JOIN {og_vocab} ov ON v.vid = ov.vid WHERE (v.module = 'og_vocab' AND ov.nid != %d) AND t.vid=v.vid";
First, give precedence to NATURAL JOIN for v and t and then LEFT JOIN with og_vocab, that is the beahvoiur of MYSQL 4.
That's all
Comments
Comment #1
paolomainardi commentedFrom MYSQL 5 Manual:
Previously, the comma operator (,) and JOIN both had the same precedence, so the join expression t1, t2 JOIN t3 was interpreted as ((t1, t2) JOIN t3). Now JOIN has higher precedence, so the expression is interpreted as (t1, (t2 JOIN t3)). This change affects statements that use an ON clause, because that clause can refer only to columns in the operands of the join, and the change in precedence changes interpretation of what those operands are.
Link: http://dev.mysql.com/doc/refman/5.0/en/join.html
Comment #2
jbomb commentedThis is still relevant for the 6.x branch. Here's a patch for paolomainardi's solution.
Comment #3
jbomb commentedCommitted to 6.x branch.
Comment #4
jbomb commentedcommitted to 5.x branch.