优秀网站下载,wordpress更换主题出错,命理网站开发,园林景观设计公司及高校人才培养建议今天给大家分享一个截止到目前位置#xff0c;我遇到最难的一道mysql题目#xff0c;非常建议大家亲手做一遍 完整代码如下#xff0c;这道题的主要难点是它有两个外键#xff0c;以前没遇到过#xff0c;我也没当回事#xff0c;分享一下错误经验哈
当时我写的where判断… 今天给大家分享一个截止到目前位置我遇到最难的一道mysql题目非常建议大家亲手做一遍 完整代码如下这道题的主要难点是它有两个外键以前没遇到过我也没当回事分享一下错误经验哈
当时我写的where判断条件是
where Users.bannedNo and(Trips.client_idUsers.users_id or Trips.driver_idUsers.users_id)
当时我就认为和下面代码写的
from Trips as T
inner join Users as U1 on T.client_idU1.users_id
inner join Users as U2 on T.driver_idU2.users_id
where U1.bannedNo and U2.bannedNo一样
我觉得系统应该会在我的系统应该像循环一样再判断完Trips.client_idUsers.users_id or 后帮我分别判断一下
Trips.client_idUsers.users_id的时候Users.bannedNo
Trips.driver_idUsers.users_id的时候Users.bannedNo
结果并不会给大家看一些官方题解其中就介绍了这个问题 反正我是狠狠的跳进了这个设计好的坑里一直爬不出来知道看了题解这个题目我觉得很好以后我希望我会经常拿出来看看。
select T2.request_at as Day,ifnull(round(T1.c/T2.c,2),0) as Cancellation Rate
from (select T.request_at,ifnull(count(*),0) as c
from Trips as T
inner join Users as U1 on T.client_idU1.users_id
inner join Users as U2 on T.driver_idU2.users_id
where U1.bannedNo and U2.bannedNo
group by T.request_at) as T2 left join
(select T.request_at,ifnull(count(*),0) as c
from Trips as T
inner join Users as U1 on T.client_idU1.users_id
inner join Users as U2 on T.driver_idU2.users_id
where U1.bannedNo and U2.bannedNo and T.status Like ca%
group by T.request_at) as T1 on T1.request_atT2.request_at;