|
Posted by Jerry Stuckle on 05/28/05 06:43
glakk@potatoradio.f2s.com wrote:
>
>
> It's really a problem with syntax I'm having. I can intuit a query to
> select
> records given ONE search keyword, but more than one? It's in the
> 'where'
> clause that I'm stumped. RTFM time, I guess. And MySQL documentation is
> nowhere as easy to use as PHP's ref.
>
> At least I know that sets won't do it.
>
> Thanks.
>
OK, lets say you have:
Table1 Table2
id primary key id foreign key on Table1(id)
other stuff Keyword
If MySQL supported the INTERSECT SQL clause, this would be easier.
However, without INTERSECT, it's still possible, i.e. (not checked...)
SELECT * FROM Table1 WHERE
id IN (SELECT id FROM Table2 WHERE Keyword='Kwd1') AND
id IN (SELECT id FROM Table2 WHERE Keyword='Kwd2') AND
id IN (SELECT id FROM Table2 WHERE Keyword='Kwd3');
This gives you all the columns in all rows in Table1 which contain kwd1
kwd2 and kwd3 (assuming Table2 is set up correctly).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|