0

SELECT time FROM my_timeslot_list WHERE date = "2019-11-12" GROUP BY time;

How do I run this query on collection factory.

This is the code  $collection = $this->collectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter('date', $date);

But this isn’t correct. Is there anyway I could do the query in collection

1 Answer 1

0

Add the following line with your code:


$collection->getSelect()->reset(\Zend_Db_Select::COLUMNS)
    ->columns('time');
$collection->getSelect()->group('time');
3
  • To the bottom of my existing code? Nov 13, 2019 at 6:23
  • @JackBrooks yes
    – Sohel Rana
    Nov 13, 2019 at 6:46
  • Okay I will give this a ago can you explain what this does please too Nov 13, 2019 at 7:02

Your Answer

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

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