You are here: Re: Help with SQL "sets" « PHP Programming Language « IT news, forums, messages
Re: Help with SQL "sets"

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация