Answer the question
In order to leave comments, you need to log in
How to get unique records from a database?
There is a column in the bot_orders table in the database that stores dates in string form
. Please tell me how to make a query through the builder or the BotOrder model to get only unique records for this column.
Answer the question
In order to leave comments, you need to log in
In order for the sql query to give you only unique rows , you need to add the word distinct to the select section.
Like this:
Roughly the same can be done through eloquent builder
However, this works with response lines.
If your response lines are different, but the date is repeated, then a more complex solution is needed there.
select distinct id, name, date...
Model::query()->distinct()...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question