在 Laravel 中加入查询
Join queries in Laravel
我在编写此查询时遇到了很多问题。有人可以请指教吗!
Select 全部来自预订 table 其中
bookings.product_id = product.id
然后根据 return,我想说如果 returned 结果 (created_at) 中的字段大于“7”,那么 return 1 否则 return 0.
假设:- 你想写 booking.product_id = product_id
如果我的假设是正确的,下面的答案可能会对你有所帮助。
with temp as(
Select * from bookings where
bookings.product_id = product_id)
select case when temp.created_at > 7 then 1 else 0
end as comparison
from temp;
如果我的假设不正确,请告诉我,以便我给你正确的答案。
$data = DB::table('product')->join('bookings','bookings.product_id','=','product.id')->get();
if($data->created_at > 7){
return 1;
}else{
return 0;
}
这是适合您的查询
我在编写此查询时遇到了很多问题。有人可以请指教吗!
Select 全部来自预订 table 其中
bookings.product_id = product.id
然后根据 return,我想说如果 returned 结果 (created_at) 中的字段大于“7”,那么 return 1 否则 return 0.
假设:- 你想写 booking.product_id = product_id 如果我的假设是正确的,下面的答案可能会对你有所帮助。
with temp as(
Select * from bookings where
bookings.product_id = product_id)
select case when temp.created_at > 7 then 1 else 0
end as comparison
from temp;
如果我的假设不正确,请告诉我,以便我给你正确的答案。
$data = DB::table('product')->join('bookings','bookings.product_id','=','product.id')->get();
if($data->created_at > 7){
return 1;
}else{
return 0;
}
这是适合您的查询