I need a MySQL query (if PHP is required you can use that too) that will delete the ending of all the values on one column named ‘url’.
The problem is that I saved the urls having the .php and now I want to delete that ending from all the values in the database.
Example:
old values:
my_url.php
my_sadas.php
new values:
my_url
my_sadas
If you want to also check whether the field ends with
'.php'before truncating, you can add this condition:Oh, there’s also
LEFT()which can be used instead ofSUBSTRING()as wellAnd
CHAR_LENGTH()should be used instead ofLENGTH()as it is multi-byte safe (whileLENGTH()is not):