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?

1 Answer 1

0

Create Model that link with table YourTable.

$Collection = Mage::getModel('module/model')->getCollection();
$Collection->getSelect()->group('ARIDNR')->having('COUNT(*) > ?', 1);
4
  • 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
    Commented Apr 6, 2018 at 6:04
  • so must be use sub query for that as a show in question
    – alpscoder
    Commented Apr 6, 2018 at 6:04
  • remove group by
    – Sourav
    Commented Apr 6, 2018 at 6:05
  • Please accept my answer & help full for other
    – Sourav
    Commented Apr 6, 2018 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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