
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Delete last value and fix two new values (VARCHAR Numbers) in MySQL declared as VARCHAR?
Let us first create a table. Here, we have VARCHAR type for value −
mysql> create table DemoTable ( Value varchar(100) ); Query OK, 0 rows affected (1.80 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('100'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('1244'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('15789'); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Value | +-------+ | 100 | | 1244 | | 15789 | +-------+ 3 rows in set (0.07 sec)
Here is the query to delete the last value and add new two varchar number values in MySQL. We have set the value 55 after deleting the last value −
mysql> update DemoTable set Value=concat(substring(Value,1,length(Value)-1), '55'); Query OK, 3 rows affected (0.23 sec) Rows matched: 3 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | Value | +--------+ | 1055 | | 12455 | | 157855 | +--------+ 3 rows in set (0.00 sec)
- Related Articles
- Set numbers as a varchar field and compare in MySQL
- How to display highest value from a string with numbers set as varchar in MySQL?
- Order VARCHAR records with string and numbers in MySQL
- MySQL Stored Procedure calling with INT and VARCHAR values
- Searching BETWEEN dates stored as varchar in MySQL?
- Perform MySQL SELECT on dates inserted into the table as VARCHAR values
- MySQL query to get the max value with numeric values in varchar field?
- Can we compare numbers in a MySQL varchar field?
- Find maximum value from a VARCHAR column in MySQL
- Update existing column data in MySQL and remove the last string from a varchar column with strings and numbers
- How to set a string with hyphen and numbers in MySQL varchar?
- Getting the maximum value from a varchar field in MySQL
- How to add duplicate varchar values without displaying error in MySQL?
- Sorting varchar field numerically in MySQL?
- Convert varchar to date in MySQL?

Advertisements