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

SvH-Shane's avatar

SQLSTATE[HY000]: General error: 1 no such column:

Hi all,

I'm getting this error: SQLSTATE[HY000]: General error: 1 no such column: aircrafts.user_id (SQL: select * from "aircrafts" where "aircrafts"."user_id" = 1 and "aircrafts"."user_id" is not null limit 1) And I don't know what to do next. The tables do exist and worked. But after a composer update, it doesn't do his job anymore.

I tried to fix it with adding public $table = "aircrafts"; to model Aircraft And it seemed to work. (For a couple of minutes, because if I want to create a user and then the whole mess started all over again.

Thanks in advance. (It's my first large Laravel project and I'm really desperate XD)

0 likes
4 replies
SvH-Shane's avatar

Thank you for the response.

I partially understand the problem (10%), but what I don't understand is why this problem appears now. It has worked all the time. (I literally didn't change anything to the code, except for the update)

I read the docs you send of Laravel but I can figure out how to use it in practice.

Below is how my model looks like from Aircraft.php. The error also called that he requests a user_id, but the model aircraft has no relation with Aircraft.

namespace App;

use Illuminate\Database\Eloquent\Model;

class Aircraft extends Model

{
	public $table = "aircraft";

	public function operator()
	{
		// Makes relation with a operator that's the aircraft from.
		return $this->belongsTo(Operator::class);
	}

	public function manufacturer()
	{
		// Relation with the builder of the aircraft, Boeing or Airbus...
		return $this->belongsTo(Manufacturer::class);
	}

	public function postAircraft()
	{
		// Relation with uploaded pictures regarding the aircraft.
		return $this->hasMany(PostAircraft::class);
	}
}

I also tried to declare in the User model aircrafts, the error disappeared but the result was that I cant create users. What I believe makes sense because It goes to the aircrafts table, instead of users.

Hopefully, you can help me and if you need some more examples let me know.

MichalOravec's avatar

If your aircrafts table doesn't have user_id column then, somewhere in your code you try to filter it by user_id

Which is this select

select * from "aircrafts" where "aircrafts"."user_id" = 1 and "aircrafts"."user_id" is not null limit 1

So just find it and fix it.

SvH-Shane's avatar

Haha, call me crazy or what so ever. But I didn't find this line of code. I looked at different ways how I could have written it, but with no result. So I don't have a clue where this is error is coming from, which all started after a composer update

Please or to participate in this conversation.