I'm new to MySQL and I'm currently trying to learn to become more efficient in it. In this case, I have a database that has people's incomes and I want to create a new column income_level
that says low, middle or high income based on the income. I have done this in four queries, but I'm sure that it could be done more efficiently? Could someone give me tips to this? Thank you!
Here are my queries so far:
ALTER TABLE Chile
ADD COLUMN `income_level` VARCHAR(50) NULL DEFAULT NULL AFTER `income`;
UPDATE Chile SET income_level = "Low income"
WHERE income < 10000;
UPDATE Chile SET income_level = "Middle income"
WHERE income > 10000;
UPDATE Chile SET income_level = "High income"
WHERE income > 100000;