Skip to content
Advertisement

MySQL – Join part of query to a new query?

I’ve got the following code which queries a table. Then it uses the result to make another query. That result is then used to make a third query.

But how do I grab the userid field from the 2nd query in order to grab a name from a users table and join that to the result of the 3rd query?

Please note once I figure out the code I will convert this to a prepared statement. It’s just easier for me to work with legacy code when figuring out queries.

JavaScript

The result I need are rows of json encoded instances of $getreplyresults with the $row[userid] from the original result joined to each row.

Advertisement

Answer

Here’s what I did in the end. Now I just have to figure out how to convert this to a prepared statement in order to avoid malicious injection.

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