I am making a query in MYSQL that brings the emails that were sent. These emails are in the emails column, separated by commas, as in the emails table sent below.
emailsenviados
IDenvio|emails
1 |[email protected],[email protected],[email protected]
2 |[email protected]
Then I need to use these emails that I'm getting as an array to make another query that will bring the name of the people of those emails, which are in the users table
ID| nome |email
1 | João |[email protected]
2 | Maria |[email protected]
3 | José |[email protected]
How can I make a single query or is it in 2 itself? At first what I thought was to make the first query and make an explode of the results to make a second query, but I caught.
My query is done like this:
$query=("SELECT id FROM emailsenviados WHERE IDenvio=1");
$db -> setQuery($query);
$incs = $db->loadResult();
and the second:
$query=("SELECT name FROM users WHERE >>AQUI SERIA A CONDIÇÃO PARA ENCONTRAR OS EMAILS<<");
$db -> setQuery($query);
$results = $db -> loadObjectList();
foreach($results as $row){
echo $nome.'<br/>';
}