Skip to content
Advertisement

Combine Two Queries into One?

I have a MySQL query that selects all audioids from a certain user in a subscribe table.

I then have another query which takes this list of audioids and matches them against a field called opids in a table called audioposts. It then selects the titles from that audioposts table and joins the users from a users table at the userid.

Is there a way I can turn these two queries into one query?

JavaScript

Here is the current two query code which I’d like to replace with one query. I’ve not yet translated this into prepared statements as it’s easier for me to visualize it the old-fashioned way. Plus I’ll be converting this into NodejS eventually anyway;

JavaScript

Advertisement

Answer

Just add another join with subscribe.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement