

- 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
Search text containing a new line in MySQL?
You can use REGEXP. Let us first create a table −
mysql> create table DemoTable ( Name varchar(100) ); Query OK, 0 rows affected (1.61 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('John\nSmith'); Query OK, 1 row affected (0.73 sec) mysql> insert into DemoTable values('John Doe'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('David\nMiller'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values('Carol Taylor'); Query OK, 1 row affected (0.27 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------------+ | Name | +--------------+ | John Smith | | John Doe | | David Miller | | Carol Taylor | +--------------+ 4 rows in set (0.00 sec)
Here is the query to search text containing a new line in MySQL −
mysql> select *from DemoTable where Name regexp "\n";
This will produce the following output −
+--------------+ | Name | +--------------+ | John Smith | | David Miller | +--------------+ 2 rows in set (0.41 sec)
- Related Questions & Answers
- Using XPATH to search text containing  
- Search for a string within text column in MySQL?
- Search for text between delimiters in MySQL?
- Remove new line characters from rows in MySQL?
- Text manipulation of strings containing “The ”? in MySQL
- Set search feature in MySQL for full text searching
- Search for PHP array element containing string?
- Update all rows by prefixing a line to every text in MySQL?
- How to match a line not containing a word in Java Regex
- Implement Text search in MongoDB
- Using a regex with text search in MongoDB
- Select column names containing a string in MySQL?
- Find a new line character with JavaScript RegExp.
- How to Create a Multi-line Text Input (Text Area) In HTML?
- Perform MongoDB full text search
Advertisements