MySQL Forums
Forum List  »  Newbie

Re: Add default value all records new column
Posted by: Phillip Ward
Date: July 11, 2022 07:17AM

Quote

I have a query with a SELECT statement ... I would love to add a new column with a static value for all records, past and future.

So, given this [simple] query ...

select a, b, c 
from table1 ; 

+---+---+---+
| a | b | c |
+---+---+---+
| 1 | 2 | 3 | 
| 4 | 5 | 6 |
+---+---+---+

... you would add the new value that you want on every record as a literal:

select a, b, c, 'S&A' as s_and_a
from table1

+---+---+---+---------+
| a | b | c | s_and_a |
+---+---+---+---------+
| 1 | 2 | 3 | S&A     |
| 4 | 5 | 6 | S&A     |
+---+---+---+---------+

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: Add default value all records new column
July 11, 2022 07:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.