我需要获取用户发布的最后一条记录。下面的下面的查询会得到我需要的信息,如果我想,如果我可以按组之前Inner Join(Select。From)
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
在第二个内部联接中添加表名 – SRIRAM
@SRIRAM:第二个内部联接不缺少表名,它缺少联接条件。 –