Ok,
Need some help regarding a JOIN SQL statement.<br><br>
I have 2 tables. 1 (tbl1) with categories (id and a name) and the other (tbl2) with a list of files (id), which document they belong to (another id) and which categoriy they belong to (a third id).<br><br>
I want to be able to pick out the categories that a page has files in. In other words - if page 1 has 3 files in category 3 and 8 files in category 4 I need a statement that returns: 3,4<br><br>
The JOIN statement I used was:<br>
select * from tbl1,tbl2 WHERE tbl1.catID=tbl2.catID AND tbl2.docID=$docID
<br><br>
It kind of works. If using my example above what it does it returns: <br>3,3,3,4,4,4,4,4,4,4,4
<br>
Instead of just returning the categories that is present (3,4) it returns the category for each file. <br><br>
I've tried some LEFT JOIN statements but I get the same result.<br><br>
Is there any way I can do this with a modified JOIN statement or should I just set up a little if-loop to put the 3 and 4 in a array by myself?
Thanks in advance!
/Bj鰎n
Need some help regarding a JOIN SQL statement.<br><br>
I have 2 tables. 1 (tbl1) with categories (id and a name) and the other (tbl2) with a list of files (id), which document they belong to (another id) and which categoriy they belong to (a third id).<br><br>
I want to be able to pick out the categories that a page has files in. In other words - if page 1 has 3 files in category 3 and 8 files in category 4 I need a statement that returns: 3,4<br><br>
The JOIN statement I used was:<br>
select * from tbl1,tbl2 WHERE tbl1.catID=tbl2.catID AND tbl2.docID=$docID
<br><br>
It kind of works. If using my example above what it does it returns: <br>3,3,3,4,4,4,4,4,4,4,4
<br>
Instead of just returning the categories that is present (3,4) it returns the category for each file. <br><br>
I've tried some LEFT JOIN statements but I get the same result.<br><br>
Is there any way I can do this with a modified JOIN statement or should I just set up a little if-loop to put the 3 and 4 in a array by myself?
Thanks in advance!
/Bj鰎n