logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Wanted Pages SQL Problem: msg#00009

Subject: Re: Wanted Pages SQL Problem
I composed this message once before but it seems to have gotten lost in the ether. I ended up figuring this one out... I got Google lucky.

According to http://dev.mysql.com/doc/refman/5.0/en/join.html:

<Quote>
INNER JOIN| and |,| (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, each and every row in the first table is joined to each and every row in the second table).

However, the precedence of the comma operator is less than than of |INNER JOIN|, |CROSS JOIN|, |LEFT JOIN|, and so on. If you mix comma joins with the other join types when there is a join condition, an error of the form |Unknown column '/|col_name|/' in 'on clause'| may occur. Information about dealing with this problem is given later in this section.
</Quote>

and sure enough later in the document they explain it. Basically prior to MySQL 5.0.12, Join and the comma operator were treated the same, but in 5.0.12 and later, the join keyword has higher precedence than the comma. So because the wanted pages code simplified is "... From link,page Join page join nonempty ..." MySQLl joins the link table last because it is joined by a comma rather than the join keyword.

The Solution:
in wiki/lib/WikiDB/backend/PearDB_mysql.php line 127:
Change
. " FROM $link_tbl,$page_tbl as linked "
To
. " FROM $link_tbl JOIN $page_tbl  as linked "

-William Leader




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


<Prev in Thread] Current Thread [Next in Thread>