

- 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
MySQL query to exclude values having specific last 3 digits
For this, use NOT IN. Let us first create a table −
mysql> create table DemoTable(Value int); Query OK, 0 rows affected (0.71 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1234); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable values(2345); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(7896); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(4321); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Value | +-------+ | 1234 | | 2345 | | 7896 | | 4321 | +-------+ 4 rows in set (0.00 sec)
Following is the query to exclude values having specific last 3 digits −
mysql> select *from DemoTable where right(Value,3) NOT IN('234','321');
This will produce the following output −
+-------+ | Value | +-------+ | 2345 | | 7896 | +-------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL query to exclude some of the values from the table
- Get the sum of last 3 digits from all the values in a column with MySQL
- MySQL query to update every alternative row string having same values?
- Query MySQL table and fetch rows posted before the last 3 days?
- How do I exclude a specific record in MySQL?
- MySQL query to select the values having multiple occurrence and display their count
- MySQL query to display only the column values with corresponding column having whitespace
- How to exclude a specific row from a table in MySQL?
- Order by last 3 chars in MySQL?
- MySQL query to count all the column values from two columns and exclude NULL values in the total count?
- MySQL query to conduct a basic search for a specific last name in a column
- Java regex to exclude a specific String constant
- MySQL query to fetch specific records matched from an array (comma separated values)
- MySQL query to sum rows having repeated corresponding Id
- How to display records having sum between a specific range using GROUP BY, HAVING and ORDER BY in a single MySQL query?
Advertisements