Reputation: 19
I'm trying to add a new column in my Family
table called Full Address
. It is basically combining values from other columns and generating the Full Address
.
I wrote the below query, but it does not seem to be working. Also, I would appreciate it if there's a better way to generate my desired value- Full Address
.
UPDATE Family SET FullAddress = (SELECT StreetAddress+', '+City+', '+State+', '+ZipCode AS Address FROM Family)
Thanks!
Upvotes: 1
Views: 70
Reputation: 1111
Try
UPDATE Family SET FullAddress = StreetAddress+', '+City+', '+State+', '+ZipCode
Upvotes: 1
Reputation: 558
Instead of using SELECT, you may try to use CONCAT in your query:
UPDATE Family SET
FullAddress = CONCAT(StreetAddress ,', ' City ,', ' STATE ,', ' ZipCode ) AS Address
Upvotes: 1
Reputation: 5656
Keep Gap between the quote if you need more space:
UPDATE Family SET
FullAddress = CONCAT(StreetAddress, ', ', City, ', ', STATE, ', ', ZipCode)
Upvotes: 2
Reputation: 1269583
Presumably, you just want this:
UPDATE Family
SET FullAddress = StreetAddress + ', ' + City + ', ' + State + ', ' + ZipCode;
Upvotes: 1