【发布时间】:2019-02-16 20:08:17
【问题描述】:
我想用 Laravel Eloquent 进行联合查询。
当我们进行 UNION 查询时,两个查询中的选定列数应该相同。
要跳过该规则,我想选择 NULL 作为Column_name,
但是 Laravel API 会自动将 NULL 替换为 'Null' 并导致错误“Null 列不存在”。
如何从 Null 中删除这些自动添加的引号?
这就是我所拥有的: 第一个查询:
...->select("Calendars.*","Services.Id as IdService","Services.Name as ServiceName","NULL as Price")
第二个查询:
...->select("Calendars.*","Services.Id as IdService","Services.Name as ServiceName","PaidService.Price")
结果是:
...union (select `Calendars`.*, `Services`.`Id` as `IdService`, `Services`.`Name` as `ServiceName`, `NULL` as `Price` from `Calendars`
非常感谢!
【问题讨论】:
标签: php laravel eloquent null quotes