SQLSTATE: Integrity constraint violation: 1052 Column ‘created_at’
I am getting this error when i am trying to join three tables in following code and the error is SQLSTATE: Integrity constraint violation: 1052 Column ‘created_at’ which i am getting when i try to run the project.
return Order::leftJoin('order_items', 'orders.id', '=', 'order_items.order_id') ->join('users', 'orders.user_id', '=', 'users.id') ->join('attendees', 'orders.id', '=', 'attendees.order_id') ->select('orders.id','orders.name','orders.order_amount','orders.billing_f_name','orders.billing_l_name','orders.billing_email', 'users.email as user_email','order_items.course_name as course_name','attendees.first_name as attendee_first_name') ->latest() ->get();
in the above program you are try to get latest records by multiple ‘created_at’ fields because your all tables have ‘created_at’ field so you need to short record by one filed you can specify table name with column name in latest function which is following
Ravindra is Web & Mobile application designer and developer. He is experienced guy in web & mobile app designing and development. He is a tech blogger too.