Joomla Jumpstart

  • Increase font size
  • Default font size
  • Decrease font size

MySQL Query: Finding newlines

E-mail Print PDF
User Rating: / 2
PoorBest 

Finding newline characters can be very useful when data may contain these unwanted characters (especially if the data will be sent into another MySQL statement). Fortunately, searching for them in MySQL is fairly easy. You just need to know what kind of newline characters you're looking to find.

 

Standard / Linux newline characters

To find all of the rows that have newlines, you can simply use the backslash (\) escape character like this:

 

SELECT * FROM articles WHERE content like '%\n%'; 

DOS / Windows newline characters

If your text is stored with DOS/Windows newline characters, use:

 

SELECT * FROM articles WHERE content like '%\r\n%';

These queries can be extremely useful when performing data cleaning on a MySQL table.

Additional sources

 
richasify $result=mysql_query("select*from hati_terdalam"); >>>>.<<<< #EXIT Dreamwever, #EXIT AppServ
by richasify. Link: MetroTwit
J7mbo That awkward moment when, after messing with PHP for an hour, you realise it's not connecting to the database because there's no mysql_query
by J7mbo. Link: RockMelt
TweeLanceJobs Help with MySQL query by klm2002: A very small task for an expert in SQL. I have two tables: jobs -... http://t.co/m3erlTHq #MySQL jobs
by TweeLanceJobs. Link: twitterfeed
GeekFreelancers New #Job: Help With MySQL Query http://t.co/x2qVDGNg
by GeekFreelancers. Link: Geek Freelancers

Google AdSense


Coffee and Cream Publishing