Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

boyjarv's avatar

Group By created_by date - error in SQL syntax

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax

here is my SQL:

Tagin::latest(DB::raw("DATE_FORMAT(created_at, %Y-%m-%d) as date"))->where('venue_id',$id)

I just want to display one date and then multiple tagins for each date

0 likes
2 replies
ajohnson6494's avatar

The latest() function simply sorts your data with the most recent record first. It takes an optional column name. It looks like you are trying to pass in part of a select statement, which will not work. Laravel Documentation

You could maybe do something like:

Tagin::where(DB::raw("created_at::date")), DB::raw("MAX(created_at::date)")->where('venue_id', $id)->get()

Please or to participate in this conversation.