Update table when both conditions are met

0

I have the following query:

    UPDATE sm4rtuniversity.badges_members SET active = 'si'
WHERE user_id IN (SELECT m.id
        FROM skill s 
        INNER JOIN skill_rel_user sru ON s.id=sru.skill_id
        INNER JOIN user u ON u.id=sru.user_id
        INNER JOIN sm4rtuniversity.members m ON m.email=u.email
        INNER JOIN sm4rtuniversity.badges b ON b.name=s.name)
AND badge_id IN (SELECT b.id
        FROM skill s 
        INNER JOIN skill_rel_user sru ON s.id=sru.skill_id
        INNER JOIN user u ON u.id=sru.user_id
        INNER JOIN sm4rtuniversity.members m ON m.email=u.email
        INNER JOIN sm4rtuniversity.badges b ON b.name=s.name)

Changes the state of the active column of the badges_members table that is in a table called sm4rtuniversity to itself when it finds a user that has a competence registered in another database called chamilo in the skill_rel_user table. And it happens the same way for the badge_id field.

The query works incorrectly, because if a user has a given competence of registration, if it is updated but not only to that user, if not to all other existing users in the database of Chamilo. Can you help me know what I'm doing wrong?

    
asked by Guillermo Ricardo Spindola Bri 27.04.2018 в 21:41
source

0 answers