-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi, I'm having trouble composing the right SQL statement for my purpose: I am building a search interface to a database with research projects. The research projects (tbl_projects) have assigned keywords in german and english, which are in a seperate table (tbl_keywords). Because I want to build a thesaurus from the keywords further on, I try to keep the number of keywords as small as possible and assign the keywords to the projects via a third table (tbl_keywords_projects).
When querying the database, I want to receive resultset which contains projects which have all of the entered keywords assigned.
I started with:
SELECT `tbl_projects`.`project_id`, FROM `tbl_projects`, `tbl_keywords_projects`, `tbl_keywords` WHERE `tbl_projects`.`project_id` = `tbl_keywords_projects`.`project_fid` AND `tbl_keywords_projects`.`keyword_fid` = `tbl_keywords`.`keyword_id` AND ( `tbl_keywords`.`keyword_de` IN ('keyword_1', 'keyword_2') OR `tbl_keywords`.`keyword_en` IN ('keyword_1', 'keyword_2') ) GROUP BY `tbl_projects`.`project_id`
but this returns all the datasets which contain at least one of the keywords. I am looking for a SELECT statement which returns only the datasets which contain all of the entered keywords. Since I am not very familiar with complex SQL statements, I tried some other expressions which always returned an empty result set.
I hope that this question is not _too_ stupid so that someone will have an answer for me, Carsten
-----BEGIN PGP SIGNATURE----- Version: 6.5.8ckt
iQA/AwUBP9cfv7jxzYr/SJ6uEQLdpACfUhB9ON/F8sv0bFqEkVIJXcEyvfEAnjJ4 RRCqfhgx38hfAtqF50fWASm9 =m7D3 -----END PGP SIGNATURE-----
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]