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

K5AD's avatar
Level 1

Column not found: 1054 Unknown column 'bookings.propID ' in 'on clause' (SQL: select * from `users` inner join `bookings` on `bookings`.`user_id` = `users`.`id` inner join `properties` on `properties`.`id` = `bookings`.`propID ` where `properties`.`user_i

Complete Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'bookings.propID ' in 'on clause' (SQL: select * from users inner join bookings on bookings.user_id = users.id inner join properties on properties.id = bookings.propID where properties.user_id = 4)

public function getuserbooked() {

    $otherBooked = DB::table('users')
    ->join('bookings', 'bookings.user_id', '=', 'users.id')
    ->join('properties', 'properties.id', '=', 'bookings.propID ')
    ->where('properties.user_id',Auth::User()->id)
    ->get();

    return view('propView.otherBooked')->with('otherBooked',$otherBooked);
    
}

I can not find the mistake please help me. all the column names are correct

0 likes
7 replies
snickfire's avatar

Can you share your database table structure? It seems that propID doesn't exist

K5AD's avatar
Level 1

@SNICKFIRE - HOW CAN i UPLOAD IMAGE HERE? But I am sure that propID exists I have checked it several time

Shawdow's avatar
Shawdow
Best Answer
Level 4

@k5ad

Try this too

$otherBooked = DB::table('users')
    ->join('bookings', 'bookings.user_id', '=', 'users.id')
    ->join('properties', 'properties.id', '=', 'bookings.propID') //u have added space here remove check it once
    ->where('properties.user_id',Auth::User()->id)
    ->get();

 
$id = Auth::User()->id;

$otherBooked = DB::table('users')
    ->join('bookings', 'bookings.user_id', '=', 'users.id')
    ->join('properties', 'properties.id', '=', 'bookings.propID') 
    ->where('properties.user_id',$id)
    ->get();

Please or to participate in this conversation.