Thursday, April 7, 2011

another mysql minus question...

Hi community,

I'm trying to achieve the following:

SELECT id, name FROM t_profiles MINUS (SELECT p.id, p.name FROM t_profiles AS p LEFT JOIN t_skills AS s ON p.id = s.id_employee WHERE s.lvl>0 and s.id_task=1)

Is there an easy way to do this in MySQL?

From stackoverflow
  • SELECT id, name FROM t_profiles 
    WHERE id not in 
       (SELECT p.id FROM t_profiles AS p 
        LEFT JOIN t_skills AS s ON p.id = s.id_employee 
        WHERE s.lvl>0 and s.id_task=1)
    

    should do the trick.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.