Merhaba arkadaşlar.
Aşağıdaki gibi bir tablom var.
Yapmak istediğim işlem şu;
question_id 1 olan ve answer 2 olan
question_id 2 olan ve answer 2 olan
question_id 3 olan ve answer 2 olan
question_id 4 olan ve answer 2 olan
question_id 5 olan ve answer 2 olan
Group by ile object_id ye gore gruplayıp hangi object_id kaç tane condition a uyuyorsa onun sayısını eşleşme_sayısı adında bir alanda tutarak almak istiyorum.
Object_id Eşleşme_sayısı
1 3
2 5
Ekran gorüntüsü;
sql kodları;
CREATE TABLE `object_answers` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`question_id` int(11) unsigned DEFAULT NULL,
`object_id` int(11) unsigned DEFAULT NULL,
`answer` int(2) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `object_answers_question_id_foreign` (`question_id`),
KEY `object_answers_object_id_foreign` (`object_id`),
CONSTRAINT `object_answers_object_id_foreign` FOREIGN KEY (`object_id`) REFERENCES `object` (`id`) ON DELETE CASCADE,
CONSTRAINT `object_answers_question_id_foreign` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;