SQLSTATE[42S22]: Column not found: 1054 Unknown column ' name' in 'where clause'
12,625
Solution 1
Sounds to me like your database is missing the name column on the authors table.
"SQLSTATE[42S22]: Column not found: 1054 Unknown column ' name' in 'where clause' (SQL: select count(*) as aggregate from authors where name = Azzario Razy Junaidi and id <> 4)
Solution 2
You have to remove space from ( name) in your AuthorsController.php here:
'name' => 'required|unique:authors, name,'
And type this:
'name' => 'required|unique:authors,name,'
and it will work 👍
Author by
Azzario Razy
Updated on June 07, 2022Comments
-
Azzario Razy over 1 year
I have some code producing the following error. How can I fix it?
"SQLSTATE[42S22]: Column not found: 1054 Unknown column ' name' in 'where clause' (SQL: select count(*) as aggregate from `authors` where ` name` = Azzario Razy Junaidi and `id` <> 4)"
AuthorsController.php public function update(Request $request, $id) { $this->validate($request, ['name' => 'required|unique:authors, name,'.$id]); $author = Author::find($id); $author->update($request->only('name')); Session::flash("flash_notification", [ "level" => "success", "message" => "Berhasil menyimpan $author->name" ]); return redirect()->route('authors.edit'); }