Reputation: 958
I have a table Orders(OrderID, OrderName, ClientCity, ClientNumber, ClientAddress, FullAddress)
. I have a task to make the FullAddress
be in the following format: ClientCity/ClientAddress-ClientNumber)
.
I have a query but I don't know if it's correct: ALTER TABLE Orders ADD CONSTRAINT CHECK(FullAddress LIKE City'/'ClientAddress'-'ClientNumber)
?
Upvotes: 0
Views: 27
Reputation: 4475
Am I right, you want to check if the FullAddress value corresponds to the other client fields ?
This will not fill the FullAddress for you, only check if you have correctly filled it.
To check the FullAddress:
ALTER TABLE Orders
ADD CONSTRAINT CHECK(FullAddress = CONCAT(City,'/',ClientAddress,'-',ClientNumber))
Not clear why you use LIKE
instead of =
Upvotes: 1