How to prefix values shorter than X
Use LPAD function.

LPAD(str,len,padstr)
Returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters.

UPDATE clients
SET clientId = LPAD(clientId, 4, '0') 
WHERE
    char_length(clientId) &lt; 4;

For example:
+------------------+
| lpad('12',4,'0') |
+------------------+
| 0012             |
+------------------+