December 2nd, 2011, 06:48 AM
Help with a if statement
hey guys, i'm new here and am stuck with a bit of sql.
i've got a project and im wondering whether it is possible to create an if statement that says something like
"If column A is NOT NULL then column B cannot be NULL"
would I have to do this as a trigger or a constraint? any help would be greatly appreciated!
December 2nd, 2011, 07:13 AM
CREATE TABLE foobar
constraint check_not_null check (foo is null or (foo is not null and bar is not null))
December 2nd, 2011, 07:37 AM
thanks, works fine