I'm trying to run this update statement, but I get this error:
SQLSTATE[HY000]: General error: 1 no such column: table2.id
DB::table('table1')
->join('table2', 'table1.row_hash', '=', 'table2.row_hash')
->where('table1.some_column', '=', 0)
->whereNull('table1.reference_no')
->update([
'table1.column_to_update' => 1,
'table1.column_to_update_2' => 1,
'table1.column_to_update_3' => 1,
'table1.reference_no' => DB::raw('table2.id') <--comment this line out and it works.
]);
If I comment out that one column from the update statement it works. I've tried using various combinations of quotes and backticks inside of the DB::raw() statement, but still get the same error. This post seems to indicate that I'm doing this the right way, but it's not cooperating.
How can I update the value of table1.reference_no to the value of table2.id? I was hoping to accomplish this in one eloquent query as it's a pretty basic SQL statement. Unfortunately I've also tried using just a raw SQL statement, which yielded other errors despite working when running it directly in my mysql client. This is taking entirely too much time for how simple it should be.
whereNullcall? That's the execution operator, so probably returning null.table2/quickbooks_transactionshave anidcolumn?