Strange mysql/pear db self join help needed.
| From: | Jim MacDiarmid | Date: | Mon, 25 Jul 2005 00:17:49 +0000 |
| Subject: | Strange mysql/pear db self join help needed. | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-26228@lists.php.net to get a copy of this message | ||
Can someone answer a MySQL question for me? I'm trying to do a self join on
my category table and I'm only coming up with 2 fields in my recordset when
I know I should have 5 fields. Here is the code I'm using.
>SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat
>FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId =
Cats2.CatId)
>LEFT JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId)
>LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId)
>WHERE Cats3.CatTypeId = 2 AND Cats.ParentId is NULL
>ORDER BY (Cats.Cat + Cats1.Cat + Cats2.Cat + Cats3.Cat)
When I execute this query in something like Navcat 2005 or SQLyog it works
fine. By the way, I'm also using the PEAR DB class.
Any ideas?
Thanks :)
Jim MacDiarmid