
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- How to delete fields with values more than a particular value in MySQL?
- Find maximum value from a VARCHAR column in MySQL
- MySQL query to find a value appearing more than once?
- Getting the maximum value from a varchar field in MySQL
- How to alter a MySQL Column from varchar(30) to varchar(100)?
- MySQL Select where value exists more than once
- Get the minimum and maximum value from a VARCHAR column and display the result in separate MySQL columns?
- Find date record after a particular date from a column with VARCHAR type in MySQL
- Get field value and convert a particular character from it to uppercase with MySQL
- How to check whether a column value is less than or greater than a certain value in R?
- How to remove a particular value from a vector in R?
- How to find a particular varchar id in MySQL from a list of values?
- How to sort more than one column at a time in MySQL?
- Subtracting a number from a single MySQL column value?
- Fetch the maximum value from a MySQL column?
Advertisements