Вы хотите обновить таблицу, используя
UPDATE groovers
SET profileImage = CASE WHEN gender = 'male' THEN 'imgM'
WHEN gender = 'female' THEN 'imgF'
ELSE 'default' END;
Схема (MySQL v5.7)
CREATE TABLE groovers
(
user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(40) NOT NULL,
firstName VARCHAR(40) NOT NULL,
lastName VARCHAR(40) NOT NULL,
gender enum ('Male', 'Female', 'Unspecified') default 'Unspecified' NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(32) NOT NULL,
profileImage VARCHAR(255) NOT NULL
);
INSERT INTO groovers VALUES (0,'test','test','test','male','test@test.com','a',''),
(0,'test','test','test','female','test@test.com','a',''),
(0,'test','test','test','Unspecified','test@test.com','a','');
UPDATE groovers
SET profileImage = CASE WHEN gender = 'male' THEN 'imgM'
WHEN gender = 'female' THEN 'imgF'
ELSE 'default' END;
Запрос # 1
SELECT * FROM groovers;
| user_id | username | firstName | lastName | gender | email | password | profileImage |
| ------- | -------- | --------- | -------- | ----------- | ------------- | -------- | ------------ |
| 1 | test | test | test | Male | test@test.com | a | imgM |
| 2 | test | test | test | Female | test@test.com | a | imgF |
| 3 | test | test | test | Unspecified | test@test.com | a | default |
Показать на БД Fiddle