0

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.

1

1 Answer 1

1

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";
Sign up to request clarification or add additional context in comments.

3 Comments

In my both query there is an array of userid.SO for that this query will work? or i have to put for-loop for that?
If you have an array of results, I array_intersect() should have worked. You should post your code and we may be able to help you with why it doesn't.
"Catchable fatal error: Object of class stdClass could not be converted to string" this error will show when i try to load the page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.