Good day. You must delete the fields (replace their values ​​with NULL ) that are smaller than 10 characters in size.

The table structure is as follows:

 ----------------------------------------- Name | City | Phone1 | Phone 2 | Phone 3 ----------------------------------------- 

I know that I need to use the condition where CHAR_LENGTH (phone1)<11 ... , but I can’t understand how to create a query.

Thanks in advance for the advice!

    1 answer 1

    UPDATE table SET phone1 = NULL WHERE CHAR_LENGTH(phone1) < 11 ?

    • thanks, wirtwelt! - Nikolay Ageev
    • Can you please tell me how to delete the last character (provided that this character is a space) in the string? - Nikolay Ageev
    • Well, look at the MySQL string functions, a lot of them, examples and information too. If specifically the last space, then read about IF, SUBSTR, LENGTH and combine. If you just need an analog trim (), then TRIM(TRAILING ' ' FROM <field> ) and where you need it - wirtwelt