Home > Enterprise >  Order by subquery MySQL
Order by subquery MySQL

Time:12-20

Hello I want to display the name of the activities according to the order of their addition in the feed (FeedId=incremented id) and with a preselected team number however the order in the subquery is not respected.

MariaDB [database]

select name from activity where id=(select ActivityId from feed where TeamId=16 order by FeedId);

I tried to take out the order by but without success. Someone would have any idea ?

CodePudding user response:

Try using inner join, something like this

select name 
from activity 
inner join feed on feed.ActivityId = activity.id
where TeamId=16 
order by FeedId;
  • Related