When visitor votes, I store information answer_id, ip, etc.
My website visitors vote in multiple polls.
I want to know visitors who vote for example ( answer_id (767) ) on what else they vote for. Based on ip. lets say answer_id=767
Table: poll_stat
`id` int(11) NOT NULL auto_increment,
`question_id` int(11) NOT NULL,
`answer_id` int(11) NOT NULL,
`ip` varchar(255) NOT NULL,
`date` date NOT NULL,
`country` text NOT NULL,
`time` int(11) NOT NULL,
`age` int(11) NOT NULL,
I think this will work for you.
edit
Hmm…you might check that there is an
INDEXcreated on the ip column. If that isn’t it, perhaps it doesn’t like the IN clause. I will rewrite as a join: