

- 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 treat MySQL longtext as integer in MySQL query?
Let us first create a table −
mysql> create table DemoTable -> ( -> Value longtext -> ); Query OK, 0 rows affected (0.94 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('778437437447488487476464644433334'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('9998888485775775757577578585'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('8888874757757757757757575675656'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('988757757574646'); Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+-----------------------------------+ | Value | +-----------------------------------+ | 778437437447488487476464644433334 | | 9998888485775775757577578585 | | 8888874757757757757757575675656 | | 988757757574646 | +-----------------------------------+ 4 rows in set (0.00 sec)
Here is the query to treat MySQL longtext as integer in query −
mysql> select * from DemoTable -> order by Value+0;
This will produce the following output −
+-----------------------------------+ | Value | +-----------------------------------+ | 988757757574646 | | 9998888485775775757577578585 | | 8888874757757757757757575675656 | | 778437437447488487476464644433334 | +-----------------------------------+ 4 rows in set (0.03 sec)
- Related Questions & Answers
- How to treat NULL as 0 and add columns in MySQL?
- Treat a MySQL column field as NULL if it is blank?
- Query for implementing MySQL LIKE as MySQL IN?
- Limit length of longtext field in MySQL SELECT results?
- In MySQL, how can we represent the time value as an integer?
- Datetime to Integer in MySQL?
- How to query soundex() in MySQL?
- How to get MySQL random integer range?
- How to concat Values in MySQL Query and to handle Null values as well?
- How to get MySQL query result in same order as given by IN clause?
- How to get file extension of file as a result of MySQL query?
- How to round down to nearest integer in MySQL?
- How to enable MySQL Query Log?
- How to query JSON datatype in MySQL?
- Setting column values as column names in the MySQL query result?
Advertisements