Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to update column with null value?

As i update column with null value, it gives me an error like this:

SQLSTATE[42S22]: Column not found: 1054 Unknown column '00:00:00' in 'field list' (SQL: update attendances set 00:00:00 = 12:11:45 where (studentid = 4 and date = 2018-07-09))

query

DB::table('attendances')
    ->where(['studentid' => $singleData['id'], 'date' => $date])
    ->update([$data['out_am'] => $time]);

my controller

[Image]

like image 466
Marc Avatar asked Sep 14 '25 14:09

Marc


1 Answers

You are using a value as a field name. It should probably be something like this:

DB::table('attendances')
    ->where(['studentid' => $singleData['id'], 'date' => $date])
    ->update(['out_am' => $data['out_am']]);
like image 50
Brian Lee Avatar answered Sep 17 '25 07:09

Brian Lee