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

0

Add the following line with your code:


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

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.