The original table table roughly as follows:
Id customer_type
111 2
112 1
113
114 2
Results the following
Id customer_type customer_id
111 2 111
112 1 112
113
114 2 114
Help leaders to help write the SQL statement
CodePudding user response:
When I found that you write programs don't like baidu, if I was advertisedCodePudding user response:
Don't need to make what the new column, it is ok to create a view:create view view_tablename
As
Select id
, customer_type
That case the when customer_type in (1, 2) then id else null end as customer_id
The from tableName
CodePudding user response:
Share the database to add a new column method