I am stuck on the following issue: I have two tables in my database. One holds parent elements and one holds child elements. This structure is given and must not be changed. I now have to update a field for each child. The field may contain 0 or 1 but must not be NULL. The default value is 0. If the parent holds a certain status, i want to update the field in the child category to 1. I have tried this so far:
UPDATE 'children' AS 'child'
SET 'foo' = (
SELECT 1
FROM 'parents' AS 'parent'
WHERE 'parent'.'type' = "bar" AND 'parent'.'id' = 'child'.'fk_parents_id'
);
This doesn't seem to work for me as I get an error message stating foo
must not be null.
I am fairly new to SQL, so I am quite stuck here. Can someone help me out?