Let's say I have this:
SELECT * FROM drivers where driver_number NOT IN (SELECT driver_number FROM buses) AND station_id = 2 OR driver_number = 'Dr_02'
Then i want to get this data as laravel query and here is what I did:
$drivers = Driver::whereRaw('driver_number not in (select driver_number from buses) AND station_id = ? ', [$station_id].' OR id = ?', [$bus->Driver_id])
->get();
But I get this error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'driver_number not in (select driver_number from buses) AND station_id = ?' at line 1 (SQL: select * from
drivers
where id = 2 driver_number not in (select driver_number from buses) AND station_id = ?)
I think there is error the way put it, that's it gets a type system error. So if anyone knows a better way to do it, you can help.