Hello I am attempting to do this with mySQL. I tried using SELECT IF and CASE to alter titles. Every title description has "A " in front of the description; even if the second word starts with a consonant. So I'm trying to query the descriptions but edit the ones with a leading consonant to start with "An ".
CASE
WHEN description LIKE ('A A%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description))
WHEN description LIKE ('A E%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description))
WHEN description LIKE ('A I%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description))
WHEN description LIKE ('A O%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description))
WHEN description LIKE ('A U%') THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description))
END;
So this particular code was just giving me Error Code: 1064 syntax.
SELECT IF(description NOT LIKE ('A A%'), NULL, CONCAT('An ', TRIM(LEADING 'A ' FROM description))),
IF(description NOT LIKE ('A E%'), null, CONCAT('An ', TRIM(LEADING 'A ' FROM description))),
IF(description NOT LIKE ('A I%'), NULL, CONCAT('An ', TRIM(LEADING 'A ' FROM description))),
IF(description NOT LIKE ('A O%'), NULL, CONCAT('An ', TRIM(LEADING 'A ' FROM description))),
IF(description NOT LIKE ('A U%'), NULL, CONCAT('An ', TRIM(LEADING 'A ' FROM description)))
FROM film_text;
This particular block of code returns separate columns however I'm trying to query all of this into one column.
What my IF block returns: