I have a Select query using joins and aliases
(yes I know its an mysql question but I like PHPBuilder..)
here's a short version of it:
$result = mysql_query("SELECT u.*, d.unit_id, d.dim1, d.dnid1, d.dim2, d.dnid2,
m1.dimname_id, m1.dimname AS dnam1, m1.dimarea AS dimare1, m2.dimname_id, m2.dimname AS dnam2 ,m2.dimarea AS dimare2
FROM tdims AS d, dimnames AS m1, dimnames AS m2
WHERE d.unit_id=u.u_id
AND d.dnid1=m1.dimname_id AND d.dnid2=m2.dimname_id
AND u_id=$uid", $db);
The real query has eight aliases for the dimname table. (It pulls dimensions and their descriptive names from the tables.)
The problem is that if the entry in the tdims table id is zero then there is no matching zero id in the dimnames.
So an unasssigned id doesnt work but I need the possibility of between 2-8 ids
I've tried
.. AND d.dnid2 !=0 but it doesnt work
I also tried forcing an id of zero into my dimname table but phpMyadmin isnt having it.
any ideas?