I have the following table structure
on which I want to perform "smart"

+-------------------+------------ ------+
| Field | Type |
| login | varchar(8) |
| keyword | varchar(25) |

The table contains users and keywords,
associated with them.
Any user can have multiple keywords,
and, any keyword can belong to multiple
users. I.e. there could be multiple rows
with the same "login" field value,
and multiple rows with the same "keyword"
field value. Thus, there's no primary key
in this table.

Now, I need to perform some "smart"
queries on this table, like select
all the users having "keyword x" OR
"keyword y" OR ... etc.
With "OR" it works fine.
But when it comes to "AND" - I'm in
trouble. Cause the same row cannot have
both "keyword x" AND "keyword y" at the
same time. So the query result is always

Any ideas on how I can perform a "smart"
query on this kind of a table?

Actually, what I really want is to be able
to enter a more complicated query
like "x OR (y AND NOT (m OR n))".

I'm entering the query in an edit box
(I have a web-based database interface),
and, since the "WHERE" clause can have
the same complexity (or, and , not,
brackets), I want to enter that query
"as is" into the "WHERE" clause of the
"SELECT" statement (with only minor changes,
like adding "keyword =" for every keyword
entered in the query (in the edit box)).

Any ideas?

Thanks in advance,