PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] I am struggling to remove the last 30 characters from data in a column

 February 18, 2022     mysql, phpmyadmin, sql     No comments   

Issue

I am looking to remove the last 30 characters from a colum within my database.

Column Name = gatewayid
Table Name = tblclients

I have created the below which works in the sense it shows me the result and it's correct but it does not commit or change anything.

SELECT gatewayid, /* ANSI Syntax */SUBSTRING( gatewayid
FROM 1 
FOR CHAR_LENGTH( gatewayid ) -30 ) AS col_trimmed, /* MySQL Syntax */SUBSTRING( gatewayid, 1, CHAR_LENGTH( gatewayid ) -30 ) AS col_trimmed
FROM tblclients

What am I missing, I am a noob :)

I expect the data in the column to remove the last 30 characters from each row.


Solution

You need to use update statement:

update tblclients 
set gatewayid = substring( gatewayid, 1, char_length( gatewayid ) -30 );


Answered By - MichaƂ Turczyn
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing