![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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)
Advertisements