by christopher.wanko » Mon Oct 27, 2025 7:43 pm
Shakadula5153 wrote: ↑Sun Sep 14, 2025 4:29 am
UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';
This is bugging me. You presumably want the year only once in the song title? What if your song title is formatted like "I Got You Babe - 1971 " ? Your SQL won't match. Your SQL *only* matches on the presence of your formatting rule. Are you sure this is what you want to have happen?
For example, you might prefer to leave any prior year formats alone for the time being:
UPDATE songs
SET songtitle = songtitle || ' (' || SUBSTR(CAST(year AS TEXT), 1, 4) || ')'
WHERE year IS NOT NULL AND year > 0 AND SUBSTR(year,1,4) BETWEEN '1900' AND '2025'
AND songtitle NOT LIKE '%'||SUBSTR(year,1,4)||'%'
;;
Just consider this.
--#
[quote=Shakadula5153 post_id=529424 time=1757842165 user_id=81033]
UPDATE Songs
SET SongTitle = SongTitle || ' (' || substr(CAST(Year AS TEXT), 1, 4) || ')'
WHERE Year IS NOT NULL
AND length(CAST(Year AS TEXT)) >= 4
AND SongTitle NOT LIKE '%(' || substr(CAST(Year AS TEXT), 1, 4) || ')';
[/quote]
This is bugging me. You presumably want the year only once in the song title? What if your song title is formatted like "I Got You Babe - 1971 " ? Your SQL won't match. Your SQL *only* matches on the presence of your formatting rule. Are you sure this is what you want to have happen?
For example, you might prefer to leave any prior year formats alone for the time being:
UPDATE songs
SET songtitle = songtitle || ' (' || SUBSTR(CAST(year AS TEXT), 1, 4) || ')'
WHERE year IS NOT NULL AND year > 0 AND SUBSTR(year,1,4) BETWEEN '1900' AND '2025'
AND songtitle NOT LIKE '%'||SUBSTR(year,1,4)||'%'
;;
Just consider this.
--#