select data which created_at today Error

Posted 1 month ago by EMfinanga

i want to get the create_at today, but i get the the below error

my code

           $salesview=DB::table('addressitems')
                 ->join('sales','sales.address_id','=','addressitems.id')
                  ->select('addressitems.clientName','sales.address_id',DB::raw('SUM(sales.amount) as 
                           totalAmount'),'addressitems.clientPhone','created_at')
                  ->whereRaw('date(created_at) = ?', [Carbon::today()])
                  ->groupby('address_id')
                 ->get();
          return view('sales.salesView', compact('salesView','salesview'));

my error

           SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in field list is ambiguous 
             (SQL: select `addressitems`.`clientName`, `sales`.`address_id`, SUM(sales.amount) as 
      totalAmount, `addressitems`.`clientPhone`, `created_at` from `addressitems` inner join `sales` on 
    `sales`.`address_id` = `addressitems`.`id` group by `address_id`)

the data is not coming, some can assist me

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.