MySQL Forums
Forum List  »  Newbie

Re: Maximum Size of Where Clause
Posted by: Nathan Ziarek
Date: July 26, 2005 07:55AM

Maybe I can break this down. I have some sample code of some JOINS that make sense (for the time being, these JOINS seem to click for me and dissapate the moment I try to use them) and I could probably use if I could get around the first part of the problem.

I have a 2-column keyword-image list:

imageid | keywordid
1 | 2
1 | 3
1 | 5
2 | 2
2 | 4
4 | 2
4 | 4
1 | 4

someone then requests all of the images that are 'attached' to keywords 2 & 4 (but this list can be much longer).

I've tried a number of "hacks" like

SELECT imageid, COUNT(*) as count FROM map_keywordimage WHERE keywordid=9 OR keywordid=33 GROUP BY imageid ORDER BY count

+---------+-------+
| imageid | count |
+---------+-------+
| 586 | 2 |
| 588 | 2 |
| 592 | 2 |
| 594 | 2 |
| 596 | 2 |
| 600 | 2 |
| 602 | 2 |
| 606 | 2 |
| 610 | 2 |
------------------

which almost works (all of the imageids with a count of 2 are the ones I want), but I am sure this is not the way to go.

Is this just not the way to organize this keyword data? I thought it would be the smartest method, but I don't seem to be able to perform a number of queries like I thought I would.

Nate

Options: ReplyQuote


Subject
Written By
Posted
Re: Maximum Size of Where Clause
July 26, 2005 07:55AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.