我需要获取用户发布的最后一条记录。如果我可以在 group by 之前进行 order by,下面的查询将获得我需要的信息
select a.client_id, a.client, b.title, b.type, b.created
from profile_users a, node b
where a.uid = b.uid
and b.type = 'event'
and a.status=1
and a.client_id in (select c.client_id
from profile_users c, follows d
where c.uid = d.followed_id
and d.following_id =3)
group by a.client_id
order by a.client_id,
b.created desc
我尝试使用内部联接重写查询,但没有得到所需的结果。我需要编写此查询,以便在检查下表中的记录后获取 client_id。我需要一些帮助来修复此查询。
select b.client_id, b.client, a.title, a.created
from node a
inner join profile_users b on a.uid=b.uid
inner join (select c.client_id
from profile_users c
inner join follows d on c.uid=d.followed_id
where c.status = 1
and d.following_id = 3
order by c.client_id
) as X1