- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get a value more than a particular value from varchar column in MySQL?
Since the column wherein you want to get the value more than a particular value is VARCHAR, use the CAST() function. For example, to fetch the value more than 999 from a column with varchar values.
Let us first create a table −
mysql> create table DemoTable ( Value varchar(100) ); Query OK, 0 rows affected (1.02 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('900'); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable values('1090'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('860'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('12345'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('908345'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+ | Value | +--------+ | 900 | | 1090 | | 860 | | 12345 | | 908345 | +--------+ 5 rows in set (0.00 sec)
Following is the query to get a value more than a particular value from varchar column −
mysql> select max(cast(Value AS SIGNED)) from DemoTable;
This will produce the following output −
+----------------------------+ | max(cast(Value AS SIGNED)) | +----------------------------+ | 908345 | +----------------------------+ 1 row in set (0.05 sec)
- Related Articles
- Find maximum value from a VARCHAR column in MySQL
- How to delete fields with values more than a particular value in MySQL?
- Get the minimum and maximum value from a VARCHAR column and display the result in separate MySQL columns?
- How to alter a MySQL Column from varchar(30) to varchar(100)?
- Getting the maximum value from a varchar field in MySQL
- Find date record after a particular date from a column with VARCHAR type in MySQL
- MySQL query to find a value appearing more than once?
- Get field value and convert a particular character from it to uppercase with MySQL
- How to find a particular varchar id in MySQL from a list of values?
- How to update all the entries except a single value in a particular column using MySQL?
- How to display highest value from a string with numbers set as varchar in MySQL?
- How to get the count of a specific value in a column with MySQL?
- Alter a table column from VARCHAR to NULL in MySQL
- How to get the current value of a particular row from a database using JDBC?
- How to check whether a column value is less than or greater than a certain value in R?

Advertisements