
-- add a col for the wolves ID
ALTER TABLE accounts ADD COLUMN id_wolves integer DEFAULT 0;

-- fill in the values
UPDATE accounts
SET id_wolves=(
    SELECT id_wolves
    FROM accounts_wolves
    WHERE accounts.mail=accounts_wolves.email
)
WHERE (
    SELECT id_wolves
    FROM accounts_wolves
    WHERE accounts.mail=accounts_wolves.email
) IS NOT NULL
