I have two queries. I didn’t knew how to make the same effect with only one. I’m not os good with SQL…
Here are pseudo-code:
friends = query("
SELECT `bio_contacts`.`contact_id`
FROM `bio_contacts`
WHERE `bio_contacts`.`user_id` = '33'
")
query("
SELECT `bio_community_events`.`id`, `bio_community_events`.`begin_on`, `bio_community_events`.`name`
FROM `bio_community_events`
WHERE `bio_community_events`.`user_id` IN friends
")
Is there any way to combine them into one query? It should improve performance, I guess. With joins, maybe?
Your query does not even need a join.
You could just say:
Or — are your field names a bit off, and should we join the following fields: bio_contacts.contact_id=bio_community_events.user_id ? In that case you can do
the following join: