Convert query in loop to single query

Hello,

Let’s say I’m displaying posts using a query (disregarding normalization) such as

SELECT * FROM posts WHERE foreign_id = x

Now, for every post I want to include what that user has on their Currently Watching list, up to 3 maximum.

So for every post I’m currently doing a

SELECT * FROM currently_watching WHERE user = x LIMIT 3

(if it were just one, i could’ve simply joined the table in the first query)
Could this be rewritten into a single query, preferably where the resulting rows would look something like

User | Message | Watching1 | Watching2 | Watching3

Thanks in advance,

not with SQL

you could put the LIMIT into a subquery, but without ORDER BY, i’m wondering why you would want to show any old three

I didn’t add the order by clause because I didn’t think it was relevant to the problem :slight_smile: