- 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
Using MySQL IN() for some column values with underscore
Let us first create a table −
mysql> create table DemoTable1363 -> ( -> StudentId varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1363 values('901'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1363 values('702'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1363 values('901_John_Doe'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1363 values('1001_Carol_Taylor'); Query OK, 1 row affected (0.26 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1363;
This will produce the following output −
+-------------------+ | StudentId | +-------------------+ | 901 | | 702 | | 901_John_Doe | | 1001_Carol_Taylor | +-------------------+ 4 rows in set (0.00 sec)
Here is the MySQL query to implement IN() −
mysql> select * from DemoTable1363 where StudentId IN('702','1001');
This will produce the following output −
+-----------+ | StudentId | +-----------+ | 702 | +-----------+ 1 row in set (0.00 sec)
- Related Articles
- Update a column in MySQL and remove the trailing underscore values
- Using UNIQUE for varchar columns with some conditions in MySQL?
- Set ENUM in MySQL for column values
- Shuffling column values with MySQL?
- MySQL ORDER BY strings with underscore?
- How to filter column values for some strings from an R data frame using dplyr?
- MySQL ENUM column match for quoted values
- How to add a leading zero to some values in a column in MySQL?
- MySQL update column to NULL for blank values
- Adding characters in values for an existing int column in MySQL?
- How to remove everything before values starting after underscore from column values of an R data frame?
- Getting maximum from a column value and set it for all other values in the same column with MySQL?
- How to quote values of single column using GROUP_CONCAT and CONCAT with DISTINCT in MySQL?
- Pad the values of the column with zeros in MySQL
- Place a specific value for NULL values in a MySQL column

Advertisements