Re: adding join conditions with DB_DataObject

From: Date: Fri, 04 Feb 2005 16:05:05 +0000
Subject: Re: adding join conditions with DB_DataObject
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17388@lists.php.net to get a copy of this message
On Friday 04 February 2005 15:53, bertrand Gugger wrote: > Then I don't understand the meaning of the request. > This > Attribute = "Framed-IP-Address" > should be in WHERE ! > e.g. for mysql, from manual: > "You should generally not have any conditions in the |ON| part that are > used to restrict which rows you want in the result set, but rather > specify these conditions in the |WHERE| clause." > à+ Adding an extra condition in the where achives something else. Example mysql> SELECT raduser.* , radreply.Value as ip FROM raduser LEFT JOIN radreply AS radreply ON radreply.UserName=raduser.username AND Attribute = "Framed-IP-Address" WHERE raduser.customerId LIKE "%MAS02%"; +------+--------------+----------+--------+-------------+------------+------+ | id | username | cbuk | active | phone | customerId | ip | +------+--------------+----------+--------+-------------+------------+------+ | 4827 | mm<snip>net | 10<snip> | 1 | 01<snip>83 | MAS02 | NULL | +------+--------------+----------+--------+-------------+------------+------+ 1 row in set (0.00 sec) mysql> SELECT raduser.* , radreply.Value as ip FROM raduser LEFT JOIN radreply AS radreply ON radreply.UserName=raduser.username WHERE raduser.customerId LIKE "%MAS02%" AND Attribute = "Framed-IP-Address"; Empty set (0.01 sec) In this case, there is actually no Framed-IP-Address for this user in the radreply column, so putting it in the WHERE causes an empty recordset wich is *not* what I want. -- Ian P. Christian http://pookey.co.uk

Attachment: [application/pgp-signature]
« previous php.pear.general (#17388) next »