I have a little problem and dont know how to get over it....
I have 3 tables:
#1 - lib
+---------+---------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------------------+------+-----+---------+----------------+
| id_lib | bigint(10) unsigned | NO | PRI | NULL | auto_increment |
| type | enum('DOC','LINK','CALC') | NO | | DOC | |
| name | varchar(50) | NO | | | |
| isEmail | tinyint(1) unsigned | NO | | 1 | |
| isWeb | tinyint(1) unsigned | NO | | 1 | |
+---------+---------------------------+------+-----+---------+----------------+
#2 - lib_cat
+---------------+---------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------------------+------+-----+---------+----------------+
| id_cat | bigint(10) unsigned | NO | PRI | NULL | auto_increment |
| id_cat_parent | bigint(10) unsigned | YES | | NULL | |
| type | enum('DOC','LINK','CALC') | NO | | DOC | |
| name | varchar(50) | NO | | | |
| sequence | smallint(2) unsigned | NO | | 0 | |
+---------------+---------------------------+------+-----+---------+----------------+
#3 - lib_cat_rel
+--------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+-------+
| id_cat | bigint(10) unsigned | NO | PRI | 0 | |
| id_lib | bigint(10) unsigned | NO | PRI | 0 | |
+--------+---------------------+------+-----+---------+-------+
I am trying to write a query that will get ALL documents from the table that are contained in one or more categories.
For instance, document 'X' is in categories '1','2','3' and document 'Y' is in '1'
If I say get all documents in categories 1 and 2 it will return document 'X'
It will not return document 'Y' because it is not in category 2.
Any help would be great.....