0

Dear All !

I have a table member_email. i have 4 columns in it.
Id
Email
CellNumber
Carrier

I want to create constraint who check following conditions,
1-Email can be null if Cellnumber is given , and Cellnumber can be null if email is given.
2-both email and cell number can not be null in one record.
3-If cellnumber is available then carrier should not be null. Carrier will be null if email is given and cellnumber is not available.

Need guidence.

Regards

2
Contributors
2
Replies
11
Views
4 Years
Discussion Span
Last Post by M.Waqas Aslam
1

Thanks for your time pritaeas. I created two constraints here is the code for others.

ALTER TABLE member_email
ADD CONSTRAINT chk_Email_Cell CHECK(
                (cellNbr is not null and email is null)
                or
                (cellNbr is null and email is not null)
    )


ALTER TABLE member_email
ADD CONSTRAINT chk_Cell_Carrier CHECK(
                (cellNbr is not null and Carrier is not null)
                or
                (cellNbr is null and Carrier is null)

    )

Thread is solved.
Regards

Votes + Comments
Thanks for sharing.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.