Reputation: 465
How do you add a column to a select statement and assign a static value, when the column does not exist?
name | address | vacationing | Zipcode
So for the example columns above, I would like to create the column on the fly of "vacationing" whose value will be assigned No for each record. I don't want to insert this column in the table permanently.
Thanks
Upvotes: 0
Views: 2382
Reputation: 13429
Do you mean something like this?
SELECT Name, Address, 'No' AS Vacationing, Zipcode
FROM MyTable
Upvotes: 5
Reputation: 5027
You cannot have a column that only exists for some of the records, and not all of them. Either create it permanently or if you like, create another table and JOIN it using the name
or id
or whatever it is you use in this table as a primary key.
Upvotes: 0