0

I am new in learning Magento. I need to create query like this,

SELECT *
FROM YourTable
WHERE ARIDNR IN (
SELECT ARIDNR
FROM YourTable
GROUP BY ARIDNR
HAVING COUNT(*) > 1
)

How to write this using collection method or any other method?

0

Create Model that link with table YourTable.

$Collection = Mage::getModel('module/model')->getCollection();
$Collection->getSelect()->group('ARIDNR')->having('COUNT(*) > ?', 1);
  • thank you so much,for answer but this query return single record with group by clause.i need to fetch all data with same id in group. – alpscoder Apr 6 '18 at 6:04
  • so must be use sub query for that as a show in question – alpscoder Apr 6 '18 at 6:04
  • remove group by – Sourav Apr 6 '18 at 6:05
  • Please accept my answer & help full for other – Sourav Apr 6 '18 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.