Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kaisdd
Starting Member
17 Posts |
Posted - 2004-11-30 : 05:33:19
|
| i´m writing on a image database application and there is a problem where i stuck.all the images in the database are indexed with keywords for the search function.i have 3 tables for that. photos, keywords, keywordindexkeywordindex stores the relation between photos and keywords. each photo has as much records in the keywordindex table as it has keywords.example:photoID | keywordID1__________101__________111__________122__________152__________103__________113__________203__________15etc....the problem is within the search function. if i like to search for keywordID IN (10,11) all works fine and i get photos where the keywordID is 10 or 11. but i don´t know how to write an sql select for getting photos with the keywordIDs 10 AND 11.any suggestions.thank you! |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-11-30 : 06:05:20
|
| select photoIDfrom tblwhere keywordID in (10,11)group by photoIDhaving count(*) = 2==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
kaisdd
Starting Member
17 Posts |
Posted - 2004-12-01 : 04:26:59
|
| thank you, works great!i´ve noticed that i have to use "having count(*) >= n" instead of "having count(*) = n"thank you! |
 |
|
|
|
|
|