[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to search a string in a mysql text field

Posted on 2014-03-07
4
Medium Priority
?
971 Views
Last Modified: 2014-03-07
Hello,

I need to search a string in a mysql text field that could contains newlines chars. Using the standard LIKE operator it does not work because the string searched is different from the text field as it contains newlines.

Here is an example:
select id from fb_posts where message like '%Fineco App. Tutti i servizi, in tutti i device. Da dove preferite collegarvi? https://welcome.fineco.it/bancaonline/extra/fineco-app%'

the string could not be found because the text field is:

Fineco App. Tutti i servizi, in tutti i device.
Da dove preferite collegarvi?

https://welcome.fineco.it/bancaonline/extra/fineco-app

So I think there should be e method to search removing newline chars.

thank you
0
Comment
Question by:apedic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39912021
Try
select id from fb_posts where message like '%Fineco App. Tutti i servizi, in tutti i device.\n Da dove preferite collegarvi? https://welcome.fineco.it/bancaonline/extra/fineco-app%'

Open in new window

or
select id from fb_posts where message like '%Fineco App. Tutti i servizi, in tutti i device.\r\n Da dove preferite collegarvi? https://welcome.fineco.it/bancaonline/extra/fineco-app%'

Open in new window

if the text is from Windows.

HTH,
Dan
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 total points
ID: 39912023
Or
SELECT id FROM fb_posts WHERE REPLACE(message,"\n","") LIKE '%Fineco App. Tutti i servizi, in tutti i device. Da dove preferite collegarvi? https://welcome.fineco.it/bancaonline/extra/fineco-app%'

Open in new window

0
 

Author Comment

by:apedic
ID: 39912074
thank you, works perfectly!
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39912093
Glad I could help!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question