2

My query is very similar to this.

(SELECT emailid FROM usereducation WHERE presfuncarea = '$funcarea') 
intersect
(SELECT emailid FROM userprofession WHERE totexpyear >= '$minexp')

Since MySQL does not support intersect, I have to find the right solution.

0

3 Answers 3

1

This should do the job :

SELECT p.emailid
FROM usereducation e JOIN userprofession p ON p.emailid = e.emailid
WHERE e.presfuncarea = '$funcarea'
AND p.totexpyear >= '$minexp'
Sign up to request clarification or add additional context in comments.

Comments

0

MySQL supports EXISTS. This should work:

SELECT UE.emailid
FROM usereducation AS UE
WHERE UE.presfuncarea = '$funcarea'
  AND NOT EXISTS
    (
    SELECT * FROM userprofession AS UP
    WHERE UE.emailid = UP.emailID AND UP.totexpyear >= '$minexp'
    )

Comments

0

From: http://www.bitbybit.dk/carsten/blog/?p=71

An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So

SELECT member_id, name FROM a
INTERSECT
SELECT member_id, name FROM b

can simply be rewritten to

SELECT a.member_id, a.name
FROM a INNER JOIN b
USING (member_id, name)

Comments

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.