- 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 search on a MySQL varchar column using a number?
Use INSERT() function from MySQL. It has the following parameters −
Parameter | Description |
---|---|
str | String to be modified |
position | Position where to insert str2 |
number | Number of characters to replace |
str2 | String to insert into str |
Let us first create a table −
mysql> create table DemoTable -> ( -> Code varchar(100) -> ); Query OK, 0 rows affected (0.82 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('958575/98') ; Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('765432/99'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('983456/91'); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-----------+ | Code | +-----------+ | 958575/98 | | 765432/99 | | 983456/91 | +-----------+ 3 rows in set (0.00 sec)
Here is the query to search on a varchar column using a number −
mysql> select *from DemoTable where Code =INSERT(76543299,7,0,'/');
Output
This will produce the following output −
+-----------+ | Code | +-----------+ | 765432/99 | +-----------+ 1 row in set (0.00 sec)
- Related Articles
- How to alter a MySQL Column from varchar(30) to varchar(100)?
- Alter a table column from VARCHAR to NULL in MySQL
- How to update a column of varchar type in MySQL to increase its length?
- Find maximum value from a VARCHAR column in MySQL
- How to get a value more than a particular value from varchar column in MySQL?
- Sorting a VARCHAR column as FLOAT using the CAST operator isn’t working in MySQL ?
- How to search a column for an exact string in MySQL?
- How to sum varchar column and display the count in MySQL?
- How to place number 0 from a column at the end maintaining the ascending search order in MySQL?
- How to select only non - numeric values from varchar column in MySQL?
- How to use MySQL LIKE query to search a column value with % in it?
- MySQL query to replace backslash from a varchar column with preceding backslash string values
- Can I search for particular numbers in a MySQL column with comma separated records using a MySQL query?
- Search for a string within text column in MySQL?
- How to increase varchar size of an existing column in a database without breaking existing data in MySQL?

Advertisements