ALTER TABLE raktar_mozgas_fej ADD COLUMN afa_mentes_forgalom smallint;
ALTER TABLE raktar_mozgas_fej ALTER COLUMN afa_mentes_forgalom SET DEFAULT 0;

UPDATE raktar_mozgas_fej SET afa_mentes_forgalom = 0;
UPDATE raktar_mozgas_fej SET afa_mentes_forgalom = 1 WHERE (SELECT COUNT(*) FROM raktar_mozgas, afa_kulcs WHERE raktar_mozgas.afakulcs = afa_kulcs.kod AND afa_kulcs.afakulcs = 0 and afa_kulcs.mentes = 1 and afa_kulcs.eus_tagorszagbeli_ertekesiteshez = 1 AND raktar_mozgas.fej_kod = raktar_mozgas_fej.kod) > 0;