Reputation: 79
In my file there is already one query name query1
and I write another query name query2
. The o/p of both query is userid
. Now I want to find the common userid
from these two queries. So is there any function for that?
The array_intersect()
function generates an error.
Upvotes: 0
Views: 47
Reputation: 780798
Use a JOIN
$query1 = "SELECT userid FROM table1";
$query2 = "SELECT userid FROM table2 WHERE something = 10";
$joinQuery = "
SELECT a.userid
FROM ($query1) AS a
JOIN ($query2) AS b
ON a.userid = b.userid";
Upvotes: 1