假设我有这个:
SELECT * FROM drivers where driver_number NOT IN (SELECT driver_number FROM buses) AND station_id = 2 OR driver_number = 'Dr_02'
它显示这些数据
然后我想将这些数据作为 Laravel 查询获取,这就是我所做的:
$drivers = Driver::whereRaw('driver_number not in (select driver_number from buses) AND station_id = ? ', [$station_id].' OR id = ?', [$bus->Driver_id]) ->get();
但我收到此错误:
SQLSTATE[42000]:语法错误或访问冲突:1064 你的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,了解在“driver_number not in (select driver_number from bus) AND station_id = ?”附近使用的正确语法 在第 1 行(SQL:select * from
drivers
where id = 2 driver_number not in (select driver_number from bus) AND station_id = ?)
我认为这样说是有错误的,那就是它得到了类型系统错误。因此,如果有人知道更好的方法,您可以提供帮助。
大话西游666
猛跑小猪
蓝山帝景